       }]
 
       # sync first parcel
-      @sync.buildActions(orderNew2, orderUpdated).update (error, response, body) =>
-
-        expect(response.statusCode).toBe 200
-        console.error body unless response.statusCode is 200
-        orderUpdated2 = body
-
-        orderNew3 = JSON.parse(JSON.stringify(orderUpdated2))
-
-        # add a parcel item
-        orderNew3.shippingInfo.deliveries[0].parcels.push {}
-
-        # sync a second parcel
-        @sync.buildActions(orderNew3, orderUpdated2).update (error, response, body) ->
-
-          expect(response.statusCode).toBe 200
-          console.error body unless response.statusCode is 200
-          orderUpdated3 = body
-
-          expect(orderUpdated3).toBeDefined()
-          parcels = _.first(orderUpdated3.shippingInfo.deliveries).parcels
-          expect(parcels.length).toBe 2
-          done()
+      @sync.buildActions(orderNew2, orderUpdated).update()
+    .then (result) ->
+      expect(result.statusCode).toBe 200
+      orderUpdated2 = result.body
+
+      orderNew3 = _.deepClone orderUpdated2
+
+      # add a parcel item
+      orderNew3.shippingInfo.deliveries[0].parcels.push {}
+
+      # sync a second parcel
+      @sync.buildActions(orderNew3, orderUpdated2).update()
+    .then (result) ->
+      expect(result.statusCode).toBe 200
+      orderUpdated3 = result.body
+
+      expect(orderUpdated3).toBeDefined()
+      parcels = _.first(orderUpdated3.shippingInfo.deliveries).parcels
+      expect(parcels.length).toBe 2
+      done()
+    .fail (error) -> done(error)
 
 ###
 helper methods

      shippingMethod:
        typeId: 'shipping-method'
        id: shippingMethod.id

createResourcePromise = (rest, url, body) ->
  deferred = Q.defer()
  rest.POST url, JSON.stringify(body), (error, response, body) ->
    if response.statusCode is 201
      deferred.resolve body
    else if error
      deferred.reject new Error(error)
    else
      deferred.reject new Error(body)
  deferred.promise

deleteResourcePromise = (rest, url) ->
  deferred = Q.defer()
  rest.DELETE url, (error, response, body) ->
    if response.statusCode is 200
      deferred.resolve body
    else if error
      deferred.reject new Error(error)
    else
      deferred.reject new Error(body)
  deferred.promise

      }]

    # prepare order: add returnInfo first
    @sync.buildActions(orderNew, @order).update()
    .then (result) =>
      orderUpdated = result.body
      orderNew2 = _.deepClone orderUpdated

      orderNew2.returnInfo[0].items[0].shipmentState = 'BackInStock'
      orderNew2.returnInfo[0].items[0].paymentState = 'Refunded'

      # update returnInfo status
      @sync.buildActions(orderNew2, orderUpdated).update()
    .then (result) ->
      expect(result.statusCode).toBe 200
      orderUpdated2 = result.body

      expect(orderUpdated2).toBeDefined()
      expect(orderUpdated2.returnInfo[0].items[0].shipmentState).toEqual orderNew2.returnInfo[0].items[0].shipmentState
      expect(orderUpdated2.returnInfo[0].items[0].paymentState).toEqual orderNew2.returnInfo[0].items[0].paymentState
      done()
    .fail (error) -> done(error)

  it 'should sync delivery items', (done) ->

    orderNew = _.deepClone @order

    # add one delivery item
    orderNew.shippingInfo.deliveries = [
