refactored tests with helper method.