refactored tests and cleaned up resources