Fix test failures depending on the environment in various ways
Several of the tests fail for me when I run it on my machine. Generally due to me running the test in a full session, rather than a clean Xvfb like in the CI.
This fixes some of these issues.