some refactoring and new tests