Refactor serialization test