major refactoring of classes and tests