Refactoring and test coverage