tests: Properly detect graphical capabilities

Some unit tests can't run in an environment which doesn't have any
graphical capabilities (for example, the CI server, or when building
RPMs for Fedora).

We were properly detecting this for older versions of the Gtk stack (e.g
Ubuntu 12.04, where our CI runs), but the detection broke in more recent
versions.

As such, the test wasn't properly skipped, and it obviously failed.

This commit fixes that, trying harder to detect the graphical
capabilities (or rather their absence), so that the appropriate tests
really are skipped when they have no chance of succeeding.

Fixes #56
Fix deprecation warning

Fixes #46
engine: Handle "other char" after an incorrect code

Fixes #57
Merge pull request #66 from Cangjians/misc

Misc fixes