refactoring + new tests