Refactoring the code to test search results too along with their types