     ) ->
       command_serve()
         .then ->
-          requestPromise(
-            method: 'GET'
-            url: envStringBaseUrl + '/error'
-          )
-        .then ([response]) ->
-          test.equal response.statusCode, 500
-          test.equal response.body, 'Server Error'
+          got envStringBaseUrl + '/error'
+        .catch got.HTTPError, (err) ->
+          test.equal err.statusCode, 500
+          test.equal err.response.body, 'Server Error'
           shutdown()
         .then ->
           test.done()

      command_serve()
        .then ->

          requestPromise(
            method: 'GET'
            url: envStringBaseUrl + '/method'
          )
        .then ([response]) ->
          test.equal response.body, 'get'

          requestPromise(
            method: 'POST'
            url: envStringBaseUrl + '/method'
          )
        .then ([response]) ->
          test.equal response.body, 'post'

          requestPromise(
            method: 'PUT'
            url: envStringBaseUrl + '/method'
          )
        .then ([response]) ->
          test.equal response.body, 'put'

          requestPromise(
            method: 'PATCH'
            url: envStringBaseUrl + '/method'
          )
        .then ([response]) ->
          test.equal response.body, 'patch'

          requestPromise(
            method: 'DELETE'
            url: envStringBaseUrl + '/method'
          )
        .then ([response]) ->
          test.equal response.body, 'delete'

          shutdown()
        .then ->

      command_serve()
        .bind({})
        .then ->
          got envStringBaseUrl + '/token',
            json: true
        .then (res) ->
          test.equal res.statusCode, 200
          test.equal res.body, null

          got.post envStringBaseUrl + '/token',
            json: true
            body:
              first_name: 'mad'
              last_name: 'max'
        .then (res) ->
          test.equal res.statusCode, 200
          test.ok res.body.token.length > 10
          this.token = res.body.token

          got envStringBaseUrl + '/token',
            json: true
            headers:
              authorization: "Bearer #{this.token}"
        .then (res) ->
          test.equal res.statusCode, 200
          test.deepEqual res.body,
            first_name: 'mad'
            last_name: 'max'

          got envStringBaseUrl + '/token',
            json: true
            headers:
              authorization: "Bearer garbagetoken"
        .then (res) ->
          test.equal res.statusCode, 200
          test.equal res.body, null

          got.post envStringBaseUrl + '/token',
            json: true
            body:
              first_name: 'bubba'
              last_name: 'zanetti'
        .then (res) ->
          test.equal res.statusCode, 200
          test.ok res.body.token.length > 10
          token = res.body.token

          got envStringBaseUrl + '/token',
            json: true
            headers:
              authorization: "Bearer #{token}"
        .then (res) ->
          test.equal res.statusCode, 200
          test.deepEqual res.body,
            first_name: 'bubba'
            last_name: 'zanetti'

          got envStringBaseUrl + '/token',
            json: true
            headers:
              authorization: "Bearer #{this.token}"
        .then (res) ->
          test.equal res.statusCode, 200
          test.deepEqual res.body,
            first_name: 'mad'
            last_name: 'max'

