serialization bug fixes

unit tests