Refactored networking client and search logic

pr to refactor networking and extend query model to include methods for testing.