Refactored classes for easier testing