Test and refactoring