Adding tests, and fixing serialization