better tests, more docs, more refactoring