Fix serialization of domain with superclass

Contains corresponding tests