You need to close the current runs() block and open another one after this -- otherwise the lines of code below will execute before the waiting is actually done.  (So this test case would still pass if the behavior broke).

Although I think in those case closing files is synchronous, so the waiting may not even be needed.