quite scary  to have global state here. probaby needs clearing after test run?