Add tests for before_search() related functions.

 Also refactor before_search() more.
Merge branch 'development' of https://github.com/kata-csc/ckanext-kata into development