New tests and refactoring.