cleanup and more unit tests