tests done, some refactoring left