refactored to clean up tests