better tests; documentation; small refactor