More work on serialization

Created tests, refined code