last tests and refactoring