first commit: refactoring + tests