Abstracted server code and tests to reflect it