Add base classes to test Serializers and Deserializers

Allows to avoid code duplication