Fixed recursive classes, added unit tests