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 #1587 from pveentjer/fix/3.x/enumtest

Fixed the Serialization of Subclassed Enumerations