Add start_server method and some error handlers.

Move start code into a method.
Return error message for invalid params.