new test and some refactoring