cleanup and unit test