refactored functional test with a helper method