Fix serialize() to pass the tests