Fix minor race condition in determining test number