Just a note: if a search fails and puts something in the error log, it prevents subsequent searches from completing. Need to address this.
Added in some comments and general housekeeping.
Separated search functions into separate module. Refactored some tests.
search function in new module and all tests passing.