refactored method to print test results