Fix syntax error and move barrier request

There was an old syntax error from when a utility function was
moved out from a class.

Moved the barrier request to be run every N times (same as table
stat check) rather then after every flow insert. Speeds up tests
by a couple orders of magnitude in general.
diff --git a/tests/caps.py b/tests/caps.py
index 4a0e355..cf6c095 100644
--- a/tests/caps.py
+++ b/tests/caps.py
@@ -90,7 +90,7 @@
     caps_logger.info("Inserting initial flow")
     rv = obj.controller.message_send(request)
     obj.assertTrue(rv != -1, "Error installing flow mod")
-    self.assertEqual(do_barrier(obj.controller), 0, "Barrier failed")
+    obj.assertEqual(do_barrier(obj.controller), 0, "Barrier failed")
     flow_count = 1
 
     caps_logger.info("Table idx: " + str(table_idx))
@@ -99,9 +99,9 @@
     while True:
         request.match.nw_src += 1
         rv = obj.controller.message_send(request)
-        self.assertEqual(do_barrier(obj.controller), 0, "Barrier failed")
         flow_count += 1
         if flow_count % count_check == 0:
+            obj.assertEqual(do_barrier(obj.controller), 0, "Barrier failed")
             response, pkt = obj.controller.transact(tstats, timeout=2)
             obj.assertTrue(response is not None, "Get tab stats failed")
             caps_logger.info(response.show())