Add tests for serializing/deserializing

Add tests.