Really fix UI tests

* For session management use file backend instead of DB, to reduce extraneous transactions
* Add `sleep(1)` to two tests which sometimes caused deadlock because there was still DB activity (reads, not writes) when the driver ended the test and truncated the tables. I can't explain how a read can cause deadlock, but it definitely does in this case.