Make sure the INSERT completes before trying the SELECT

There's a race condition here, where random tests can fail to find the row because the insert hasn't completed yet.