Moved out to a test utility, since this is only there for unit tests.