added more cleanup code in tests