cleanup and added more tests