Fixed the Serialization of Subclassed Enumerations

Certain enumerations like TimeUnit rely on subclassing the enclosing enumeration.
This fix makes sure we can correctly deal with these types of enumerations.
Merge pull request #1588 from pveentjer/fix/3.maintenance/enumtest

Fixed the Serialization of Subclassed Enumerations