Fix global leak in tests