Add search tests, fix bug in backwards search

Since the changes for #394, the search command is parsed with an extra
regular expression to split the command into token and flags.

However, the backward search character '?' is reserved in regex
and needs even more escaping.

Fixes #418.