Fixed UpsertTest by running DB setup in a separate transaction so that records are
committed to the database before the upsert operation begins.