Fix test.py.

It may detect the need-screen-escape incorrectly or not invoke the vim
subprocess in the first test case.  These could be fixed by adding a
short sleep.
Code cleanup for test.py.
Solves waiting problem in an elegant way.

1. The keys after launching vim will wait until the vim is full loaded.
2. The keys after leaving vim will wait until the vim process is dead.
3. A bunch of cleanups.
Fix tmux interface.
Refactor: split test.py into several smaller files.
Implement priority-based clearsnippets.
Code cleanup.

Full tested and does not break and old tests.