Rewrite server so tests pass.