Fixing a race between the session being closed and the call to commit in the async handler that caused some exceptions occasionally in the test run.