Add unit testing for serialization

Adds an automatic unit test for SerializationUtils and fixes a few bugs
in SerializationUtils itself.