Extracted out some test code into its own function