Clean up GraphUtilities internal state in test teardown

To fix the issue that test cases report different results for the second run.