new tests and fixes after refactoring