Refactored functional_test with utility function