Tests + refactoring.