added tests, with few bugs due to polymorphic issue