Port receiving search result from old code
Port getting total count
Add handler for working with search query
Remove useless locks in tests