testing enhancements and refactoring