Add tests and build serialize method