refactored runTests method