Fix problems with test(), require inside function