refactoring, improving tests