This patch starts using state.cmdstate.write() which uses cbor as serialization
format to write histedit-state files.
Compatibility for reading old state files using new code is maintained.
Some changes in test which depended on the format of histedit state file.