restclient encodes now the search query string.

also some refactoring to avoid duplication