PROTON-2524 Fix intermittent test failure

Ensure that expected async processing from last call is completed before
moving onto next operation to prevent test from failing due to frames
not being in the expect order scripted.
diff --git a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ReceiverTest.java b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ReceiverTest.java
index feaf692..8f88e35 100644
--- a/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ReceiverTest.java
+++ b/protonj2-client/src/test/java/org/apache/qpid/protonj2/client/impl/ReceiverTest.java
@@ -2690,12 +2690,17 @@
           assertNotNull(receiver.receive()); // #2
 
           peer.waitForScriptToComplete();
+          peer.expectAttach().ofSender().respond();
+          peer.expectDetach().respond();
           if (autoAccept)
           {
               peer.expectDisposition().withFirst(2);
           }
           peer.expectFlow().withLinkCredit(3);
 
+          // Ensure that no additional frames from last receive overlap with this one
+          connection.openSender("test").openFuture().get().close();
+
           // Now consume message 3 which will trip the replenish barrier and the
           // credit should be updated to reflect that we still have 7 queued
           assertNotNull(receiver.receive());  // #3
@@ -2714,12 +2719,17 @@
           assertNotNull(receiver.receive()); // #5
 
           peer.waitForScriptToComplete();
+          peer.expectAttach().ofSender().respond();
+          peer.expectDetach().respond();
           if (autoAccept)
           {
               peer.expectDisposition().withFirst(5);
           }
           peer.expectFlow().withLinkCredit(6);
 
+          // Ensure that no additional frames from last receive overlap with this one
+          connection.openSender("test").openFuture().get().close();
+
           // Consume number 6 which means we only have 4 outstanding plus the three
           // that we sent last time we flowed which is 70% of possible prefetch so
           // we should flow to top off credit which would be 6 since we have four
diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonIncomingDelivery.java b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonIncomingDelivery.java
index 89d0d40..e3e63e2 100644
--- a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonIncomingDelivery.java
+++ b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonIncomingDelivery.java
@@ -57,12 +57,9 @@
     private EventHandler<IncomingDelivery> deliveryUpdatedEventHandler = null;
 
     /**
-     * @param link
-     *      The link that this delivery is associated with
-     * @param deliveryId
-     *      The Delivery Id that is assigned to this delivery.
-     * @param deliveryTag
-     *      The delivery tag assigned to this delivery
+     * @param link        The link that this delivery is associated with
+     * @param deliveryId  The Delivery Id that is assigned to this delivery.
+     * @param deliveryTag The delivery tag assigned to this delivery
      */
     public ProtonIncomingDelivery(ProtonReceiver link, long deliveryId, DeliveryTag deliveryTag) {
         this.deliveryId = deliveryId;
@@ -180,7 +177,7 @@
         return disposition(localState, true);
     }
 
-    //----- Payload access
+    // ----- Payload access
 
     @Override
     public int available() {
@@ -259,7 +256,7 @@
         return this;
     }
 
-    //----- Incoming Delivery event handlers
+    // ----- Incoming Delivery event handlers
 
     @Override
     public ProtonIncomingDelivery deliveryReadHandler(EventHandler<IncomingDelivery> handler) {
@@ -291,7 +288,7 @@
         return deliveryUpdatedEventHandler;
     }
 
-    //----- Internal methods to manage the Delivery
+    // ----- Internal methods to manage the Delivery
 
     @Override
     public int getTransferCount() {
@@ -365,4 +362,11 @@
 
         return this;
     }
+
+    @Override
+    public String toString() {
+        return "ProtonIncomingDelivery { " +
+                    "deliveryId = " + deliveryId + ", " +
+                    "deliveryTag = " + deliveryTag + " };";
+    }
 }
diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonOutgoingDelivery.java b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonOutgoingDelivery.java
index 19e1548..b550504 100644
--- a/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonOutgoingDelivery.java
+++ b/protonj2/src/main/java/org/apache/qpid/protonj2/engine/impl/ProtonOutgoingDelivery.java
@@ -258,6 +258,13 @@
         return deliveryUpdatedEventHandler;
     }
 
+    @Override
+    public String toString() {
+        return "ProtonOutgoingDelivery { " +
+                "deliveryId = " + deliveryId + ", " +
+                "deliveryTag = " + deliveryTag + " };";
+    }
+
     //----- Internal methods meant only for use by Proton resources
 
     private void tryRetireDeliveryTag() {