Change encode to serialize.
Adjust unit tests for serializers.