Move some test code that is no longer shared out of Util.