Make uitests more robust

  * When fetching trees from the database the queries are now scoped to the test instance to prevent other data in the database from interfering with assertions.

  * I was running into intermittent failures in some of the tests which, showed up more when running with a virtual display. Adding delays between steps appeared to resolve the issue.