fixes scope leaks in tests
renames functions for clarity