add tests and clean up