refactor, add tests, update readme.

Should now produce expected results on all tests.
can you add yourself as a `maintainer`?