streamline middleware error handling

Uses the convention where a middleware with an arity of 4 is assumed to be the
error handler.
initial unit test commit for refactored tunnel middleware
simplify response logic with express response sugar

With unit tests!