Refactored classes and tests