Moved nested quicksearch api helper function outside; added unit tests for quicksearch api