add tests and cleanup a bit