clean up server.py
abstract core search out so it can be mocked