Stop running tests giving warnings

Rescope some vars & abstract some globally useful test functions up a level.