Testing and refactoring