Fix finding tessdata dir and other stuff

This fixes all but 1 error with `make check` on my PC.

I don't know enough about Xorg/x-sessions to fix the selftest, but these commits
at least make the test fail rather than hang indefinitely.