unit test coverage and refactoring