refactoring, add new tests