Move creation of test env into a fn.