Refactoring to increase test coverage