Test coverage and refactoring