refactored the test class to eliminate duplicate code