refactoring + documentation; added first unit tests