cleanup, make more testable and add tests
update readme