Index: /trunk/src/VBox/Main/glue/tests/TestVBox.java
===================================================================
--- /trunk/src/VBox/Main/glue/tests/TestVBox.java	(revision 56635)
+++ /trunk/src/VBox/Main/glue/tests/TestVBox.java	(revision 56636)
@@ -73,4 +73,5 @@
                     es.eventProcessed(listener, ev);
                 }
+                // process system event queue
                 mgr.waitForEvents(0);
             }
@@ -116,4 +117,5 @@
             }
         }
+        // process system event queue
         mgr.waitForEvents(0);
     }
@@ -124,5 +126,7 @@
         while (!p.getCompleted())
         {
+            // process system event queue
             mgr.waitForEvents(0);
+            // wait for completion of the task, but at most 200 msecs
             p.waitForCompletion(200);
             if (System.currentTimeMillis() >= end)
@@ -142,4 +146,5 @@
         progressBar(mgr, p, 10000);
         session.unlockMachine();
+        // process system event queue
         mgr.waitForEvents(0);
     }
@@ -166,4 +171,5 @@
             session1.unlockMachine();
             session2.unlockMachine();
+            // process system event queue
             mgr1.waitForEvents(0);
             mgr2.waitForEvents(0);
@@ -188,4 +194,5 @@
             off += buf.length;
         }
+        // process system event queue
         mgr.waitForEvents(0);
     }
@@ -271,4 +278,5 @@
         }
 
+        // process system event queue
         mgr.waitForEvents(0);
         if (ws)
Index: /trunk/src/VBox/Main/glue/tests/TestVBoxNATEngine.java
===================================================================
--- /trunk/src/VBox/Main/glue/tests/TestVBoxNATEngine.java	(revision 56635)
+++ /trunk/src/VBox/Main/glue/tests/TestVBoxNATEngine.java	(revision 56636)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2013 Oracle Corporation
+ * Copyright (C) 2013-2015 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -15,5 +15,5 @@
  * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
  */
-import org.virtualbox_4_3.*;
+import org.virtualbox_5_0.*;
 import java.util.List;
 import java.util.Arrays;
@@ -85,4 +85,7 @@
             inaccessible = true;
         }            
+
+        // process system event queue
+        mgr.waitForEvents(0);
     }
 
@@ -91,4 +94,6 @@
         System.out.println("\nAttempting to start VM '" + vm.getName() + "'");
         mgr.startVm(vm.getName(), null, 7000);
+        // process system event queue
+        mgr.waitForEvents(0);
     }
 
@@ -152,5 +157,4 @@
                         testEnumeration(mgr, vbox, vm);
                         testStart(mgr, vbox, vm);
-                        //testEvents(mgr, vbox.getEventSource());
                     }
                     System.out.println("done, press Enter...");
@@ -167,4 +171,7 @@
                 e.printStackTrace();
             }
+
+        // process system event queue
+        mgr.waitForEvents(0);
 
         if (ws)
