add tests and other cleanup