I'm not crazy about this function being defined within a test function. Was that intentional?

I think this will be confusing to some people. What do you think about moving it outside of the test function?