Fix JSON serialization / deserialization
Add test for serialisation