Fix race condition in graph_test