fix(linux): Refactor and fix tests
fix(linux): Refactor and fix tests

- patch `is_fcitx_running()` so that tests will work without X11
- move common test code to methods
- move some tests to subtests

tavultesoft/keymanweb,tavultesoft/keymanweb