Added mutex for thread safety
[iotcloud.git] / version2 / src / java / iotcloud / Test.java
index fcbc44dfe5a2a2aabeb91a6b3ee0bcd27544b540..0de2e5c0ae8b47d9307af527c560d4cd57139ce6 100644 (file)
@@ -1,5 +1,8 @@
 package iotcloud;
 
+import java.util.List;
+import java.util.ArrayList;
+
 /**
  * Test cases.
  * @author Brian Demsky
@@ -8,9 +11,9 @@ package iotcloud;
 
 public class Test {
 
-       public static final  int NUMBER_OF_TESTS = 1000;
+       public static final  int NUMBER_OF_TESTS = 100;
 
-       public static void main(String[] args) {
+       public static void main(String[] args)  throws ServerException, InterruptedException {
                if (args[0].equals("2")) {
                        test2();
                } else if (args[0].equals("3")) {
@@ -27,21 +30,37 @@ public class Test {
                        test8();
                } else if (args[0].equals("9")) {
                        test9();
+               } else if (args[0].equals("10")) {
+                       test10();
+               } else if (args[0].equals("11")) {
+                       test11();
                }
        }
 
-       static void test9() {
+
+       static void test11() throws InterruptedException {
+
+               boolean foundError = false;
 
                // Setup the 2 clients
-               Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
-               t1.initTable();
-               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
-               t2.update();
+               Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               while (true) {
+                       try {
+                               t1.initTable();
+                               break;
+                       } catch (Exception e) {}
+               }
+
+               Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               while (t2.update().getFirst() == false) {}
 
+               LocalComm lc = new LocalComm(t1, t2);
+               t1.addLocalComm(t2.getId(), lc);
+               t2.addLocalComm(t1.getId(), lc);
 
                // Make the Keys
                System.out.println("Setting up keys");
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+               for (int i = 0; i < 4; i++) {
                        String a = "a" + i;
                        String b = "b" + i;
                        String c = "c" + i;
@@ -50,96 +69,178 @@ public class Test {
                        IoTString ib = new IoTString(b);
                        IoTString ic = new IoTString(c);
                        IoTString id = new IoTString(d);
-                       t1.createNewKey(ia, 321);
-                       t1.createNewKey(ib, 351);
-                       t2.createNewKey(ic, 321);
-                       t2.createNewKey(id, 351);
+                       while (true) {
+                               try {
+                                       t1.createNewKey(ia, 321);
+                                       break;
+                               } catch (Exception e) {}
+                       }
+
+                       while (true) {
+                               try {
+                                       t1.createNewKey(ib, 351);
+                                       break;
+                               } catch (Exception e) {}
+                       }
+
+                       while (true) {
+                               try {
+                                       t2.createNewKey(ic, 321);
+                                       break;
+                               } catch (Exception e) {}
+                       }
+
+                       while (true) {
+                               try {
+                                       t2.createNewKey(id, 351);
+                                       break;
+                               } catch (Exception e) {}
+                       }
                }
 
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-                       String a = "a" + i;
-                       String b = "b" + i;
-                       String c = "c" + i;
-                       String d = "d" + i;
-                       IoTString ia = new IoTString(a);
-                       IoTString ib = new IoTString(b);
-                       IoTString ic = new IoTString(c);
-                       IoTString id = new IoTString(d);
-                       t1.createNewKey(ia, 1000);
-                       t1.createNewKey(ib, 1000);
-                       t2.createNewKey(ic, 1000);
-                       t2.createNewKey(id, 1000);
+               // Do Updates for the keys
+               System.out.println("Setting Key-Values...");
+               for (int t = 0; t < NUMBER_OF_TESTS; t++) {
+                       for (int i = 0; i < 4; i++) {
+                               String keyA = "a" + i;
+                               String valueA = "a" + (i + t);
+
+                               IoTString iKeyA = new IoTString(keyA);
+                               IoTString iValueA = new IoTString(valueA);
+
+                               t1.startTransaction();
+                               t1.addKV(iKeyA, iValueA);
+                               t1.commitTransaction();
+                       }
                }
 
-               System.out.println("Updating Clients...");
-               t1.update();
-               t2.update();
-               t1.update();
-               t2.update();
+               t2.updateFromLocal(321);
+
+               System.out.println("Checking Key-Values...");
+               for (int i = 0; i < 4; i++) {
+
+                       String keyA = "a" + i;
+                       String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
+
+                       IoTString iKeyA = new IoTString(keyA);
+                       IoTString iValueA = new IoTString(valueA);
+
+                       IoTString testValA1 = t1.getCommitted(iKeyA);
+                       IoTString testValA2 = t2.getCommitted(iKeyA);
+
+                       if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyA + "    " + testValA1 + "    " + iValueA);
+                               foundError = true;
+                       }
+
+                       if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2 + "    " + iValueA);
+                               foundError = true;
+                       }
+               }
+
+               if (foundError) {
+                       System.out.println("Found Errors...");
+               } else {
+                       System.out.println("No Errors Found...");
+               }
+       }
+
+       static void test10() throws InterruptedException {
 
                boolean foundError = false;
 
+               // Setup the 2 clients
+               Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               while (true) {
+                       try {
+                               t1.rebuild();
+                               break;
+                       } catch (Exception e) {}
+               }
+
+               Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               while (true) {
+                       try {
+                               t2.rebuild();
+                               break;
+                       } catch (Exception e) {}
+               }
+
+               LocalComm lc = new LocalComm(t1, t2);
+               t1.addLocalComm(t2.getId(), lc);
+               t2.addLocalComm(t1.getId(), lc);
+
+
                System.out.println("Checking Key-Values...");
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+               for (int i = 0; i < 4; i++) {
 
                        String keyA = "a" + i;
                        String keyB = "b" + i;
                        String keyC = "c" + i;
                        String keyD = "d" + i;
+                       String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
+                       String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
+                       String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
+                       String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
 
                        IoTString iKeyA = new IoTString(keyA);
                        IoTString iKeyB = new IoTString(keyB);
                        IoTString iKeyC = new IoTString(keyC);
                        IoTString iKeyD = new IoTString(keyD);
+                       IoTString iValueA = new IoTString(valueA);
+                       IoTString iValueB = new IoTString(valueB);
+                       IoTString iValueC = new IoTString(valueC);
+                       IoTString iValueD = new IoTString(valueD);
 
 
-                       Long testValA1 = t1.getArbitrator(iKeyA);
-                       Long testValB1 = t1.getArbitrator(iKeyB);
-                       Long testValC1 = t1.getArbitrator(iKeyC);
-                       Long testValD1 = t1.getArbitrator(iKeyD);
+                       IoTString testValA1 = t1.getCommitted(iKeyA);
+                       IoTString testValB1 = t1.getCommitted(iKeyB);
+                       IoTString testValC1 = t1.getCommitted(iKeyC);
+                       IoTString testValD1 = t1.getCommitted(iKeyD);
 
-                       Long testValA2 = t2.getArbitrator(iKeyA);
-                       Long testValB2 = t2.getArbitrator(iKeyB);
-                       Long testValC2 = t2.getArbitrator(iKeyC);
-                       Long testValD2 = t2.getArbitrator(iKeyD);
+                       IoTString testValA2 = t2.getCommitted(iKeyA);
+                       IoTString testValB2 = t2.getCommitted(iKeyB);
+                       IoTString testValC2 = t2.getCommitted(iKeyC);
+                       IoTString testValD2 = t2.getCommitted(iKeyD);
 
-                       if ((testValA1 == null) || (testValA1 != 321)) {
-                               System.out.println("Key-Value t1 incorrect: " + keyA + "    " + testValA1);
+                       if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyA + "    " + testValA1 + "    " + iValueA);
                                foundError = true;
                        }
 
-                       if ((testValB1 == null) || (testValB1 != 351)) {
-                               System.out.println("Key-Value t1 incorrect: " + keyB + "    " + testValB1);
+                       if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyB + "    " + testValB1 + "    " + iValueB);
                                foundError = true;
                        }
 
-                       if ((testValC1 == null) || (testValC1 != 321)) {
-                               System.out.println("Key-Value t1 incorrect: " + keyC + "    " + testValC1);
+                       if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyC + "    " + testValC1 + "    " + iValueC);
                                foundError = true;
                        }
 
-                       if ((testValD1 == null) || (testValD1 != 351)) {
-                               System.out.println("Key-Value t1 incorrect: " + keyD + "    " + testValD1);
+                       if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyD + "    " + testValD1 + "    " + iValueD);
                                foundError = true;
                        }
 
-                       if ((testValA2 == null) || (testValA2 != 321)) {
-                               System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
+                       if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2 + "    " + iValueA);
                                foundError = true;
                        }
 
-                       if ((testValB2 == null) || (testValB2 != 351)) {
-                               System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                       if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2 + "    " + iValueB);
                                foundError = true;
                        }
 
-                       if ((testValC2 == null) || (testValC2 != 321)) {
-                               System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
+                       if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2 + "    " + iValueC);
                                foundError = true;
                        }
 
-                       if ((testValD2 == null) || (testValD2 != 351)) {
-                               System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
+                       if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2 + "    " + iValueD);
                                foundError = true;
                        }
                }
@@ -151,22 +252,32 @@ public class Test {
                }
        }
 
-       static void test8() {
+       static void test9() throws InterruptedException {
 
                boolean foundError = false;
+               List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
 
                // Setup the 2 clients
-               Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
-               t1.initTable();
-               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
-               t2.update();
+               Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               while (true) {
+                       try {
+                               t1.initTable();
+                               break;
+                       } catch (Exception e) {}
+               }
+
+               Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               while (t2.update().getFirst() == false) {}
+
+               // LocalComm lc = new LocalComm(t1, t2);
+               // t1.addLocalComm(t2.getId(), lc);
+               // t2.addLocalComm(t1.getId(), lc);
+
 
-               // t1.rebuild();
-               // t2.rebuild();
 
                // Make the Keys
                System.out.println("Setting up keys");
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+               for (int i = 0; i < 4; i++) {
                        String a = "a" + i;
                        String b = "b" + i;
                        String c = "c" + i;
@@ -175,105 +286,153 @@ public class Test {
                        IoTString ib = new IoTString(b);
                        IoTString ic = new IoTString(c);
                        IoTString id = new IoTString(d);
-                       t1.createNewKey(ia, 321);
-                       t1.createNewKey(ib, 351);
-                       t2.createNewKey(ic, 321);
-                       t2.createNewKey(id, 351);
-               }
+                       while (true) {
+                               try {
+                                       t1.createNewKey(ia, 321);
+                                       break;
+                               } catch (Exception e) {}
+                       }
+
+                       while (true) {
+                               try {
+                                       t1.createNewKey(ib, 351);
+                                       break;
+                               } catch (Exception e) {}
+                       }
+
+                       while (true) {
+                               try {
+                                       t2.createNewKey(ic, 321);
+                                       break;
+                               } catch (Exception e) {}
+                       }
 
+                       while (true) {
+                               try {
+                                       t2.createNewKey(id, 351);
+                                       break;
+                               } catch (Exception e) {}
+                       }
+               }
 
                // Do Updates for the keys
                System.out.println("Setting Key-Values...");
 
+               for (int t = 0; t < NUMBER_OF_TESTS; t++) {
+                       for (int i = 0; i < 4; i++) {
+                               String keyB = "b" + i;
+                               String valueB = "b" + (i + t);
 
-               String keyA0 = "a0";
-               String keyB0 = "b0";
-               String keyC0 = "c0";
-               String keyD0 = "d0";
-               String valueA0 = "a0";
-               String valueB0 = "b0";
-               String valueC0 = "c0";
-               String valueD0 = "d0";
-
-               IoTString iKeyA0 = new IoTString(keyA0);
-               IoTString iKeyB0 = new IoTString(keyB0);
-               IoTString iKeyC0 = new IoTString(keyC0);
-               IoTString iKeyD0 = new IoTString(keyD0);
-               IoTString iValueA0 = new IoTString(valueA0);
-               IoTString iValueB0 = new IoTString(valueB0);
-               IoTString iValueC0 = new IoTString(valueC0);
-               IoTString iValueD0 = new IoTString(valueD0);
-
-               t1.startTransaction();
-               t1.addKV( iKeyA0, iValueA0);
-               t1.commitTransaction();
-
-               t1.startTransaction();
-               t1.addKV(iKeyB0, iValueB0);
-               t1.commitTransaction();
-
-               t2.startTransaction();
-               t2.addKV(iKeyC0, iValueC0);
-               t2.commitTransaction();
-
-               t2.startTransaction();
-               t2.addKV(iKeyD0, iValueD0);
-               t2.commitTransaction();
-
-               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
-                       String keyB = "b" + i;
-                       String valueB = "b" + i;
-                       IoTString iKeyB = new IoTString(keyB);
-                       IoTString iValueB = new IoTString(valueB);
-
-                       String keyBOld = "b" + (i - 1);
-                       String valueBOld = "b" + (i - 1);
-                       IoTString iKeyBOld = new IoTString(keyBOld);
-                       IoTString iValueBOld = new IoTString(valueBOld);
+                               IoTString iKeyB = new IoTString(keyB);
+                               IoTString iValueB = new IoTString(valueB);
 
 
-                       t1.startTransaction();
-                       t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyBOld, iValueBOld, Guard.Equal))));
-                       t1.addKV(iKeyB, iValueB);
-                       t1.commitTransaction();
+                               t1.startTransaction();
+                               t1.getSpeculativeAtomic(iKeyB);
+                               t1.addKV(iKeyB, iValueB);
+                               transStatusList.add(t1.commitTransaction());
+                       }
                }
 
-               System.out.println("Checking Key-Values...");
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+               while (t1.update().getFirst() == false) {}
 
-                       String keyB = "b" + i;
-                       String valueB = "b" + i;
 
+               for (int i = 0; i < 4; i++) {
+
+                       String keyB = "b" + i;
+                       String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
                        IoTString iKeyB = new IoTString(keyB);
                        IoTString iValueB = new IoTString(valueB);
 
                        IoTString testValB1 = t1.getSpeculative(iKeyB);
+                       IoTString testValB2 = t2.getSpeculative(iKeyB);
 
                        if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
-                               System.out.println("Key-Value t1 incorrect: " + keyB);
+                               System.out.println("Key-Value t1 incorrect: " + keyB + "    " + testValB1);
+                               foundError = true;
+                       }
+
+                       if ((testValB2 != null)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                               foundError = true;
+                       }
+               }
+
+               for (int t = 0; t < NUMBER_OF_TESTS; t++) {
+                       for (int i = 0; i < 4; i++) {
+                               String keyC = "c" + i;
+                               String valueC = "c" + (i + t);
+
+                               IoTString iKeyC = new IoTString(keyC);
+                               IoTString iValueC = new IoTString(valueC);
+
+                               t2.startTransaction();
+                               t2.getSpeculativeAtomic(iKeyC);
+                               t2.addKV(iKeyC, iValueC);
+                               transStatusList.add(t2.commitTransaction());
+                       }
+               }
+
+               while (t2.update().getFirst() == false) {}
+
+               for (int i = 0; i < 4; i++) {
+                       String keyC = "c" + i;
+                       String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
+                       IoTString iKeyC = new IoTString(keyC);
+                       IoTString iValueC = new IoTString(valueC);
+
+                       IoTString testValC1 = t1.getSpeculative(iKeyC);
+                       IoTString testValC2 = t2.getSpeculative(iKeyC);
+
+                       if ((testValC1 != null)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyC + "   " + testValC1);
                                foundError = true;
+                       }
 
+                       if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyC + "   " + testValC2);
+                               foundError = true;
                        }
                }
 
+               for (int t = 0; t < NUMBER_OF_TESTS; t++) {
+                       for (int i = 0; i < 4; i++) {
+                               String keyA = "a" + i;
+                               String keyD = "d" + i;
+                               String valueA = "a" + (i + t);
+                               String valueD = "d" + (i + t);
+
+                               IoTString iKeyA = new IoTString(keyA);
+                               IoTString iKeyD = new IoTString(keyD);
+                               IoTString iValueA = new IoTString(valueA);
+                               IoTString iValueD = new IoTString(valueD);
+
+
+                               t1.startTransaction();
+                               t1.addKV(iKeyA, iValueA);
+                               transStatusList.add(t1.commitTransaction());
+
+                               t2.startTransaction();
+                               t2.addKV(iKeyD, iValueD);
+                               transStatusList.add(t2.commitTransaction());
+                       }
+               }
 
                System.out.println("Updating Clients...");
-               t1.update();
-               t2.update();
-               t1.update();
-               t2.update();
+               while (t1.update().getFirst() == false) {}
+               while (t2.update().getFirst() == false) {}
 
                System.out.println("Checking Key-Values...");
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+               for (int i = 0; i < 4; i++) {
 
                        String keyA = "a" + i;
                        String keyB = "b" + i;
                        String keyC = "c" + i;
                        String keyD = "d" + i;
-                       String valueA = "a" + i;
-                       String valueB = "b" + i;
-                       String valueC = "c" + i;
-                       String valueD = "d" + i;
+                       String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
+                       String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
+                       String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
+                       String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
 
                        IoTString iKeyA = new IoTString(keyA);
                        IoTString iKeyB = new IoTString(keyB);
@@ -295,91 +454,299 @@ public class Test {
                        IoTString testValC2 = t2.getCommitted(iKeyC);
                        IoTString testValD2 = t2.getCommitted(iKeyD);
 
+                       if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyA + "    " + testValA1 + "    " + iValueA);
+                               foundError = true;
+                       }
 
-                       if (i == 0) {
-                               if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyA);
-                                       foundError = true;
-                               }
-
-                               if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyB);
-                                       foundError = true;
-                               }
+                       if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyB + "    " + testValB1 + "    " + iValueB);
+                               foundError = true;
+                       }
 
-                               if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyC);
-                                       foundError = true;
-                               }
+                       if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyC + "    " + testValC1 + "    " + iValueC);
+                               foundError = true;
+                       }
 
-                               if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyD);
-                                       foundError = true;
-                               }
+                       if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyD + "    " + testValD1 + "    " + iValueD);
+                               foundError = true;
+                       }
 
+                       if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2 + "    " + iValueA);
+                               foundError = true;
+                       }
 
-                               if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
-                                       foundError = true;
-                               }
+                       if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2 + "    " + iValueB);
+                               foundError = true;
+                       }
 
-                               if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
-                                       foundError = true;
-                               }
+                       if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2 + "    " + iValueC);
+                               foundError = true;
+                       }
 
-                               if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
-                                       foundError = true;
-                               }
+                       if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2 + "    " + iValueD);
+                               foundError = true;
+                       }
+               }
 
-                               if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
-                                       foundError = true;
-                               }
-                       } else {
-                               if (testValA1 != null) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyA);
-                                       foundError = true;
-                               }
+               for (TransactionStatus status : transStatusList) {
+                       if (status.getStatus() != TransactionStatus.StatusCommitted) {
+                               foundError = true;
+                               System.out.println(status.getStatus());
+                       }
+               }
 
-                               if (testValB1 != null) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyB);
-                                       foundError = true;
-                               }
+               if (foundError) {
+                       System.out.println("Found Errors...");
+               } else {
+                       System.out.println("No Errors Found...");
+               }
+       }
 
-                               if (testValC1 != null) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyC);
-                                       foundError = true;
-                               }
+       static void test8() throws InterruptedException {
 
-                               if (testValD1 != null) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyD);
-                                       foundError = true;
-                               }
+               boolean foundError = false;
+               List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
+
+               // Setup the 2 clients
+               Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               while (true) {
+                       try {
+                               t1.initTable();
+                               break;
+                       } catch (Exception e) {}
+               }
+
+               Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               while (t2.update().getFirst() == false) {}
+
+               LocalComm lc = new LocalComm(t1, t2);
+               t1.addLocalComm(t2.getId(), lc);
+               t2.addLocalComm(t1.getId(), lc);
+
+               // Make the Keys
+               System.out.println("Setting up keys");
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+                       System.out.println(i);
+
+                       String a = "a" + i;
+                       String b = "b" + i;
+                       String c = "c" + i;
+                       String d = "d" + i;
+                       IoTString ia = new IoTString(a);
+                       IoTString ib = new IoTString(b);
+                       IoTString ic = new IoTString(c);
+                       IoTString id = new IoTString(d);
+
+                       while (true) {
+                               try {
+                                       t1.createNewKey(ia, 321);
+                                       break;
+                               } catch (Exception e) {}
+                       }
+
+                       while (true) {
+                               try {
+                                       t1.createNewKey(ib, 351);
+                                       break;
+                               } catch (Exception e) {}
+                       }
 
-                               if (testValA2 != null) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
+                       while (true) {
+                               try {
+                                       t2.createNewKey(ic, 321);
+                                       break;
+                               } catch (Exception e) {}
+                       }
+
+                       while (true) {
+                               try {
+                                       t2.createNewKey(id, 351);
+                                       break;
+                               } catch (Exception e) {}
+                       }
+               }
+
+               // Do Updates for the keys
+               System.out.println("Setting Key-Values...");
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+                       System.out.println(i);
+                       String keyA = "a" + i;
+                       String keyB = "b" + i;
+                       String keyC = "c" + i;
+                       String keyD = "d" + i;
+                       String valueA = "a" + i;
+                       String valueB = "b" + i;
+                       String valueC = "c" + i;
+                       String valueD = "d" + i;
+
+                       IoTString iKeyA = new IoTString(keyA);
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iKeyC = new IoTString(keyC);
+                       IoTString iKeyD = new IoTString(keyD);
+                       IoTString iValueA = new IoTString(valueA);
+                       IoTString iValueB = new IoTString(valueB);
+                       IoTString iValueC = new IoTString(valueC);
+                       IoTString iValueD = new IoTString(valueD);
+
+
+                       String keyAPrev = "a" + (i - 1);
+                       String keyBPrev = "b" + (i - 1);
+                       String keyCPrev = "c" + (i - 1);
+                       String keyDPrev = "d" + (i - 1);
+                       String valueAPrev = "a" + (i - 1);
+                       String valueBPrev = "b" + (i - 1);
+                       String valueCPrev = "c" + (i - 1);
+                       String valueDPrev = "d" + (i - 1);
+
+                       IoTString iKeyAPrev = new IoTString(keyAPrev);
+                       IoTString iKeyBPrev = new IoTString(keyBPrev);
+                       IoTString iKeyCPrev = new IoTString(keyCPrev);
+                       IoTString iKeyDPrev = new IoTString(keyDPrev);
+                       IoTString iValueAPrev = new IoTString(valueAPrev);
+                       IoTString iValueBPrev = new IoTString(valueBPrev);
+                       IoTString iValueCPrev = new IoTString(valueCPrev);
+                       IoTString iValueDPrev = new IoTString(valueDPrev);
+
+                       t1.startTransaction();
+                       if (i != 0) {
+                               IoTString tmp = t1.getSpeculative(iKeyAPrev);
+                               if ((tmp == null) || !tmp.equals(iValueAPrev)) {
+                                       System.out.println("Key a Error: " + i);
                                        foundError = true;
                                }
+                       }
+                       t1.addKV(iKeyA, iValueA);
+                       transStatusList.add(t1.commitTransaction());
+
+
 
-                               if (testValB2 != null) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                       t1.startTransaction();
+                       if (i != 0) {
+                               IoTString tmp = t1.getSpeculative(iKeyBPrev);
+                               if ((tmp == null) || !tmp.equals(iValueBPrev)) {
+                                       System.out.println("Key b Error: " + i);
                                        foundError = true;
                                }
+                       }
+                       t1.addKV(iKeyB, iValueB);
+                       transStatusList.add(t1.commitTransaction());
+
 
-                               if (testValC2 != null) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
+                       t2.startTransaction();
+                       if (i != 0) {
+                               IoTString tmp = t2.getSpeculative(iKeyCPrev);
+                               if ((tmp == null) || !tmp.equals(iValueCPrev)) {
+                                       System.out.println("Key c Error: " + i);
                                        foundError = true;
                                }
+                       }
+                       t2.addKV(iKeyC, iValueC);
+                       transStatusList.add(t2.commitTransaction());
 
-                               if (testValD2 != null) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
+                       t2.startTransaction();
+                       if (i != 0) {
+                               IoTString tmp = t2.getSpeculative(iKeyDPrev);
+                               if ((tmp == null) || !tmp.equals(iValueDPrev)) {
+                                       System.out.println("Key d Error: " + i);
                                        foundError = true;
                                }
                        }
+                       t2.addKV(iKeyD, iValueD);
+                       transStatusList.add(t2.commitTransaction());
+               }
+
+
+               System.out.println("Updating...");
+               while (t1.update().getFirst() == false) {}
+               while (t2.update().getFirst() == false) {}
+
+
+               System.out.println("Checking Key-Values...");
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+
+                       String keyA = "a" + i;
+                       String keyB = "b" + i;
+                       String keyC = "c" + i;
+                       String keyD = "d" + i;
+                       String valueA = "a" + i;
+                       String valueB = "b" + i;
+                       String valueC = "c" + i;
+                       String valueD = "d" + i;
+
+                       IoTString iKeyA = new IoTString(keyA);
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iKeyC = new IoTString(keyC);
+                       IoTString iKeyD = new IoTString(keyD);
+                       IoTString iValueA = new IoTString(valueA);
+                       IoTString iValueB = new IoTString(valueB);
+                       IoTString iValueC = new IoTString(valueC);
+                       IoTString iValueD = new IoTString(valueD);
+
+
+                       IoTString testValA1 = t1.getCommitted(iKeyA);
+                       IoTString testValB1 = t1.getCommitted(iKeyB);
+                       IoTString testValC1 = t1.getCommitted(iKeyC);
+                       IoTString testValD1 = t1.getCommitted(iKeyD);
+
+                       IoTString testValA2 = t2.getCommitted(iKeyA);
+                       IoTString testValB2 = t2.getCommitted(iKeyB);
+                       IoTString testValC2 = t2.getCommitted(iKeyC);
+                       IoTString testValD2 = t2.getCommitted(iKeyD);
+
+                       if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyA);
+                               foundError = true;
+                       }
+
+                       if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyB);
+                               foundError = true;
+                       }
+
+                       if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyC);
+                               foundError = true;
+                       }
+
+                       if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyD);
+                               foundError = true;
+                       }
+
+
+                       if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
+                               foundError = true;
+                       }
+
+                       if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                               foundError = true;
+                       }
+
+                       if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
+                               foundError = true;
+                       }
+
+                       if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
+                               foundError = true;
+                       }
                }
 
+               for (TransactionStatus status : transStatusList) {
+                       if (status.getStatus() != TransactionStatus.StatusCommitted) {
+                               foundError = true;
+                       }
+               }
                if (foundError) {
                        System.out.println("Found Errors...");
                } else {
@@ -387,24 +754,20 @@ public class Test {
                }
        }
 
-       static void test7() {
+       static void test7() throws ServerException, InterruptedException {
 
-               long startTime = 0;
-               long endTime = 0;
+               boolean foundError = false;
+               List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
 
                // Setup the 2 clients
-               Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
                t1.initTable();
-               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
                t2.update();
 
-               // t1.rebuild();
-               // t2.rebuild();
-
                // Make the Keys
                System.out.println("Setting up keys");
-               startTime = System.currentTimeMillis();
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+               for (int i = 0; i < 4; i++) {
                        String a = "a" + i;
                        String b = "b" + i;
                        String c = "c" + i;
@@ -418,148 +781,120 @@ public class Test {
                        t2.createNewKey(ic, 321);
                        t2.createNewKey(id, 351);
                }
-               endTime = System.currentTimeMillis();
-
-               System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
-               System.out.println("Time Taken Per Key: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
-               System.out.println();
-
 
                // Do Updates for the keys
                System.out.println("Setting Key-Values...");
-               startTime = System.currentTimeMillis();
-
-
-
-               String keyA0 = "a0";
-               String keyB0 = "b0";
-               String keyC0 = "c0";
-               String keyD0 = "d0";
-               String valueA0 = "a0";
-               String valueB0 = "b0";
-               String valueC0 = "c0";
-               String valueD0 = "d0";
-
-               IoTString iKeyA0 = new IoTString(keyA0);
-               IoTString iKeyB0 = new IoTString(keyB0);
-               IoTString iKeyC0 = new IoTString(keyC0);
-               IoTString iKeyD0 = new IoTString(keyD0);
-               IoTString iValueA0 = new IoTString(valueA0);
-               IoTString iValueB0 = new IoTString(valueB0);
-               IoTString iValueC0 = new IoTString(valueC0);
-               IoTString iValueD0 = new IoTString(valueD0);
 
-               t1.startTransaction();
-               t1.addKV( iKeyA0, iValueA0);
-               t1.commitTransaction();
+               for (int t = 0; t < NUMBER_OF_TESTS; t++) {
+                       for (int i = 0; i < 4; i++) {
+                               String keyB = "b" + i;
+                               String valueB = "b" + (i + t);
 
-               t1.startTransaction();
-               t1.addKV(iKeyB0, iValueB0);
-               t1.commitTransaction();
+                               IoTString iKeyB = new IoTString(keyB);
+                               IoTString iValueB = new IoTString(valueB);
 
-               t2.startTransaction();
-               t2.addKV(iKeyC0, iValueC0);
-               t2.commitTransaction();
+                               t1.startTransaction();
+                               t1.getSpeculativeAtomic(iKeyB);
+                               t1.addKV(iKeyB, iValueB);
+                               transStatusList.add(t1.commitTransaction());
+                       }
+               }
 
-               t2.startTransaction();
-               t2.addKV(iKeyD0, iValueD0);
-               t2.commitTransaction();
+               for (int i = 0; i < 4; i++) {
 
-               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
                        String keyB = "b" + i;
-                       String valueB = "b" + i;
+                       String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
                        IoTString iKeyB = new IoTString(keyB);
                        IoTString iValueB = new IoTString(valueB);
 
-                       String keyBOld = "b" + (i - 1);
-                       String valueBOld = "b" + (i - 2);
-                       IoTString iKeyBOld = new IoTString(keyBOld);
-                       IoTString iValueBOld = new IoTString(valueBOld);
+                       IoTString testValB1 = t1.getSpeculative(iKeyB);
+                       IoTString testValB2 = t2.getSpeculative(iKeyB);
 
+                       if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyB + "    " + testValB1);
+                               foundError = true;
+                       }
 
-                       t1.startTransaction();
-                       t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyBOld, iValueBOld, Guard.Equal))));
-                       t1.addKV(iKeyB, iValueB);
-                       t1.commitTransaction();
+                       if ((testValB2 != null)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                               foundError = true;
+                       }
                }
 
-               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
+               for (int t = 0; t < NUMBER_OF_TESTS; t++) {
+                       for (int i = 0; i < 4; i++) {
+                               String keyC = "c" + i;
+                               String valueC = "c" + (i + t);
+
+                               IoTString iKeyC = new IoTString(keyC);
+                               IoTString iValueC = new IoTString(valueC);
+
+                               t2.startTransaction();
+                               t2.getSpeculativeAtomic(iKeyC);
+                               t2.addKV(iKeyC, iValueC);
+                               transStatusList.add(t2.commitTransaction());
+                       }
+               }
+
+               for (int i = 0; i < 4; i++) {
                        String keyC = "c" + i;
-                       String valueC = "c" + i;
+                       String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
                        IoTString iKeyC = new IoTString(keyC);
                        IoTString iValueC = new IoTString(valueC);
 
-                       String keyCOld = "c" + (i - 1);
-                       String valueCOld = "c" + (i - 2);
-                       IoTString iKeyCOld = new IoTString(keyCOld);
-                       IoTString iValueCOld = new IoTString(valueCOld);
+                       IoTString testValC1 = t1.getSpeculative(iKeyC);
+                       IoTString testValC2 = t2.getSpeculative(iKeyC);
 
+                       if ((testValC1 != null)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyC + "   " + testValC1);
+                               foundError = true;
+                       }
 
-                       t2.startTransaction();
-                       t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyCOld, iValueCOld, Guard.Equal))));
-                       t2.addKV(iKeyC, iValueC);
-                       t2.commitTransaction();
+                       if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyC + "   " + testValC2);
+                               foundError = true;
+                       }
                }
 
-               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
-                       String keyA = "a" + i;
-                       String keyD = "d" + i;
-                       String valueA = "a" + i;
-                       String valueD = "d" + i;
-
-                       IoTString iKeyA = new IoTString(keyA);
-                       IoTString iKeyD = new IoTString(keyD);
-                       IoTString iValueA = new IoTString(valueA);
-                       IoTString iValueD = new IoTString(valueD);
-
-
-                       String keyAOld = "a" + (i - 1);
-                       String keyDOld = "d" + (i - 1);
-                       String valueAOld = "a" + (i - 2);
-                       String valueDOld = "d" + (i - 2);
-                       IoTString iKeyAOld = new IoTString(keyAOld);
-                       IoTString iKeyDOld = new IoTString(keyDOld);
-                       IoTString iValueAOld = new IoTString(valueAOld);
-                       IoTString iValueDOld = new IoTString(valueDOld);
+               for (int t = 0; t < NUMBER_OF_TESTS; t++) {
+                       for (int i = 0; i < 4; i++) {
+                               String keyA = "a" + i;
+                               String keyD = "d" + i;
+                               String valueA = "a" + (i + t);
+                               String valueD = "d" + (i + t);
 
+                               IoTString iKeyA = new IoTString(keyA);
+                               IoTString iKeyD = new IoTString(keyD);
+                               IoTString iValueA = new IoTString(valueA);
+                               IoTString iValueD = new IoTString(valueD);
 
-                       t1.startTransaction();
-                       t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyAOld, iValueAOld, Guard.Equal))));
-                       t1.addKV(iKeyA, iValueA);
-                       t1.commitTransaction();
+                               t1.startTransaction();
+                               t1.addKV(iKeyA, iValueA);
+                               transStatusList.add(t1.commitTransaction());
 
-                       t2.startTransaction();
-                       t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyDOld, iValueDOld, Guard.Equal))));
-                       t2.addKV(iKeyD, iValueD);
-                       t2.commitTransaction();
+                               t2.startTransaction();
+                               t2.addKV(iKeyD, iValueD);
+                               transStatusList.add(t2.commitTransaction());
+                       }
                }
 
-               endTime = System.currentTimeMillis();
-
-               System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
-               System.out.println("Time Taken Per Update: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
-               System.out.println();
-
-
                System.out.println("Updating Clients...");
                t1.update();
                t2.update();
                t1.update();
                t2.update();
 
-               boolean foundError = false;
-
                System.out.println("Checking Key-Values...");
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+               for (int i = 0; i < 4; i++) {
 
                        String keyA = "a" + i;
                        String keyB = "b" + i;
                        String keyC = "c" + i;
                        String keyD = "d" + i;
-                       String valueA = "a" + i;
-                       String valueB = "b" + i;
-                       String valueC = "c" + i;
-                       String valueD = "d" + i;
+                       String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
+                       String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
+                       String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
+                       String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
 
                        IoTString iKeyA = new IoTString(keyA);
                        IoTString iKeyB = new IoTString(keyB);
@@ -581,88 +916,50 @@ public class Test {
                        IoTString testValC2 = t2.getCommitted(iKeyC);
                        IoTString testValD2 = t2.getCommitted(iKeyD);
 
+                       if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyA + "    " + testValA1);
+                               foundError = true;
+                       }
 
-                       if (i == 0) {
-                               if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyA);
-                                       foundError = true;
-                               }
-
-                               if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyB);
-                                       foundError = true;
-                               }
-
-                               if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyC);
-                                       foundError = true;
-                               }
-
-                               if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyD);
-                                       foundError = true;
-                               }
-
-
-                               if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
-                                       foundError = true;
-                               }
-
-                               if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
-                                       foundError = true;
-                               }
-
-                               if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
-                                       foundError = true;
-                               }
-
-                               if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
-                                       foundError = true;
-                               }
-                       } else {
-                               if (testValA1 != null) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyA);
-                                       foundError = true;
-                               }
+                       if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyB + "    " + testValB1);
+                               foundError = true;
+                       }
 
-                               if (testValB1 != null) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyB);
-                                       foundError = true;
-                               }
+                       if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyC + "    " + testValC1);
+                               foundError = true;
+                       }
 
-                               if (testValC1 != null) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyC);
-                                       foundError = true;
-                               }
+                       if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyD + "    " + testValD1);
+                               foundError = true;
+                       }
 
-                               if (testValD1 != null) {
-                                       System.out.println("Key-Value t1 incorrect: " + keyD);
-                                       foundError = true;
-                               }
+                       if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
+                               foundError = true;
+                       }
 
-                               if (testValA2 != null) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
-                                       foundError = true;
-                               }
+                       if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                               foundError = true;
+                       }
 
-                               if (testValB2 != null) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
-                                       foundError = true;
-                               }
+                       if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
+                               foundError = true;
+                       }
 
-                               if (testValC2 != null) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
-                                       foundError = true;
-                               }
+                       if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
+                               foundError = true;
+                       }
+               }
 
-                               if (testValD2 != null) {
-                                       System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
-                                       foundError = true;
-                               }
+               for (TransactionStatus status : transStatusList) {
+                       if (status.getStatus() != TransactionStatus.StatusCommitted) {
+                               foundError = true;
                        }
                }
 
@@ -673,23 +970,19 @@ public class Test {
                }
        }
 
-       static void test6() {
+       static void test6() throws ServerException, InterruptedException {
 
-               long startTime = 0;
-               long endTime = 0;
+               boolean foundError = false;
+               List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
 
                // Setup the 2 clients
-               Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
                t1.initTable();
-               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
                t2.update();
 
-               // t1.rebuild();
-               // t2.rebuild();
-
                // Make the Keys
                System.out.println("Setting up keys");
-               startTime = System.currentTimeMillis();
                for (int i = 0; i < NUMBER_OF_TESTS; i++) {
                        String a = "a" + i;
                        String b = "b" + i;
@@ -704,117 +997,52 @@ public class Test {
                        t2.createNewKey(ic, 321);
                        t2.createNewKey(id, 351);
                }
-               endTime = System.currentTimeMillis();
-
-               System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
-               System.out.println("Time Taken Per Key: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
-               System.out.println();
-
 
                // Do Updates for the keys
                System.out.println("Setting Key-Values...");
-               startTime = System.currentTimeMillis();
-
-
-               t1.startTransaction();
-               t1.addKV( new IoTString("a0"), new IoTString("a0"));
-               t1.commitTransaction();
-
-               t1.startTransaction();
-               t1.addKV(new IoTString("b0"), new IoTString("b0"));
-               t1.commitTransaction();
-
-               t2.startTransaction();
-               t2.addKV(new IoTString("c0"), new IoTString("c0"));
-               t2.commitTransaction();
-
-               t2.startTransaction();
-               t2.addKV(new IoTString("d0"), new IoTString("d0"));
-               t2.commitTransaction();
-
-               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+                       String keyA = "a" + i;
                        String keyB = "b" + i;
-                       String valueB = "b" + i;
-                       IoTString iKeyB = new IoTString(keyB);
-                       IoTString iValueB = new IoTString(valueB);
-
-                       String keyBOld = "b" + (i - 1);
-                       String valueBOld = "b" + (i - 1);
-                       IoTString iKeyBOld = new IoTString(keyBOld);
-                       IoTString iValueBOld = new IoTString(valueBOld);
-
-
-                       t1.startTransaction();
-                       t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyBOld, iValueBOld, Guard.Equal))));
-                       t1.addKV(iKeyB, iValueB);
-                       t1.commitTransaction();
-               }
-
-               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
                        String keyC = "c" + i;
-                       String valueC = "c" + i;
-                       IoTString iKeyC = new IoTString(keyC);
-                       IoTString iValueC = new IoTString(valueC);
-
-                       String keyCOld = "c" + (i - 1);
-                       String valueCOld = "c" + (i - 1);
-                       IoTString iKeyCOld = new IoTString(keyCOld);
-                       IoTString iValueCOld = new IoTString(valueCOld);
-
-
-                       t2.startTransaction();
-                       t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyCOld, iValueCOld, Guard.Equal))));
-                       t2.addKV(iKeyC, iValueC);
-                       t2.commitTransaction();
-               }
-
-               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
-                       String keyA = "a" + i;
                        String keyD = "d" + i;
                        String valueA = "a" + i;
+                       String valueB = "b" + i;
+                       String valueC = "c" + i;
                        String valueD = "d" + i;
 
                        IoTString iKeyA = new IoTString(keyA);
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iKeyC = new IoTString(keyC);
                        IoTString iKeyD = new IoTString(keyD);
                        IoTString iValueA = new IoTString(valueA);
+                       IoTString iValueB = new IoTString(valueB);
+                       IoTString iValueC = new IoTString(valueC);
                        IoTString iValueD = new IoTString(valueD);
 
-
-                       String keyAOld = "a" + (i - 1);
-                       String keyDOld = "d" + (i - 1);
-                       String valueAOld = "a" + (i - 1);
-                       String valueDOld = "d" + (i - 1);
-                       IoTString iKeyAOld = new IoTString(keyAOld);
-                       IoTString iKeyDOld = new IoTString(keyDOld);
-                       IoTString iValueAOld = new IoTString(valueAOld);
-                       IoTString iValueDOld = new IoTString(valueDOld);
-
-
                        t1.startTransaction();
-                       t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyAOld, iValueAOld, Guard.Equal))));
+                       t1.getCommittedAtomic(iKeyA);
                        t1.addKV(iKeyA, iValueA);
-                       t1.commitTransaction();
+                       transStatusList.add(t1.commitTransaction());
+
+                       t1.startTransaction();
+                       t1.getCommittedAtomic(iKeyB);
+                       t1.addKV(iKeyB, iValueB);
+                       transStatusList.add(t1.commitTransaction());
+
+                       t2.startTransaction();
+                       t2.getCommittedAtomic(iKeyC);
+                       t2.addKV(iKeyC, iValueC);
+                       transStatusList.add(t2.commitTransaction());
 
                        t2.startTransaction();
-                       t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyDOld, iValueDOld, Guard.Equal))));
+                       t2.getCommittedAtomic(iKeyD);
                        t2.addKV(iKeyD, iValueD);
-                       t2.commitTransaction();
+                       transStatusList.add(t2.commitTransaction());
                }
 
-               endTime = System.currentTimeMillis();
-
-               System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
-               System.out.println("Time Taken Per Update: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
-               System.out.println();
-
-
                System.out.println("Updating Clients...");
                t1.update();
                t2.update();
-               t1.update();
-               t2.update();
-
-               boolean foundError = false;
 
                System.out.println("Checking Key-Values...");
                for (int i = 0; i < NUMBER_OF_TESTS; i++) {
@@ -890,6 +1118,12 @@ public class Test {
                        }
                }
 
+               for (TransactionStatus status : transStatusList) {
+                       if (status.getStatus() != TransactionStatus.StatusCommitted) {
+                               foundError = true;
+                       }
+               }
+
                if (foundError) {
                        System.out.println("Found Errors...");
                } else {
@@ -897,26 +1131,21 @@ public class Test {
                }
        }
 
-       static void test5() {
+       static void test5() throws ServerException, InterruptedException {
 
-               long startTime = 0;
-               long endTime = 0;
+               boolean foundError = false;
+               List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
 
                // Setup the 2 clients
-               Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
                t1.initTable();
-               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
                t2.update();
 
-               // t1.rebuild();
-               // t2.rebuild();
-
-
 
                // Make the Keys
                System.out.println("Setting up keys");
-               startTime = System.currentTimeMillis();
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+               for (int i = 0; i < 4; i++) {
                        String a = "a" + i;
                        String b = "b" + i;
                        String c = "c" + i;
@@ -930,123 +1159,117 @@ public class Test {
                        t2.createNewKey(ic, 321);
                        t2.createNewKey(id, 351);
                }
-               endTime = System.currentTimeMillis();
 
+               // Do Updates for the keys
+               System.out.println("Setting Key-Values...");
 
+               for (int t = 0; t < NUMBER_OF_TESTS; t++) {
+                       for (int i = 0; i < 4; i++) {
+                               String keyB = "b" + i;
+                               String valueB = "b" + (i + t);
 
-               System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
-               System.out.println("Time Taken Per Key: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
-               System.out.println();
+                               IoTString iKeyB = new IoTString(keyB);
+                               IoTString iValueB = new IoTString(valueB);
 
+                               t1.startTransaction();
+                               t1.addKV(iKeyB, iValueB);
+                               transStatusList.add(t1.commitTransaction());
+                       }
+               }
 
-               // Do Updates for the keys
-               System.out.println("Setting Key-Values...");
-               startTime = System.currentTimeMillis();
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-                       String keyA = "a" + i;
-                       String keyB = "b" + i;
-                       String keyC = "c" + i;
-                       String keyD = "d" + i;
-                       String valueA = "a" + i;
-                       String valueB = "b" + i;
-                       String valueC = "c" + i;
-                       String valueD = "d" + i;
+               for (int i = 0; i < 4; i++) {
 
-                       IoTString iKeyA = new IoTString(keyA);
+                       String keyB = "b" + i;
+                       String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
                        IoTString iKeyB = new IoTString(keyB);
-                       IoTString iKeyC = new IoTString(keyC);
-                       IoTString iKeyD = new IoTString(keyD);
-                       IoTString iValueA = new IoTString(valueA);
                        IoTString iValueB = new IoTString(valueB);
-                       IoTString iValueC = new IoTString(valueC);
-                       IoTString iValueD = new IoTString(valueD);
 
+                       IoTString testValB1 = t1.getSpeculative(iKeyB);
+                       IoTString testValB2 = t2.getSpeculative(iKeyB);
 
+                       if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyB);
+                               foundError = true;
+                       }
 
-                       if (i != 0) {
-                               String keyAOld = "a" + (i - 1);
-                               String keyBOld = "b" + (i - 1);
-                               String keyCOld = "c" + (i - 1);
-                               String keyDOld = "d" + (i - 1);
-                               String valueAOld = "a" + (i - 1);
-                               String valueBOld = "b" + (i - 1);
-                               String valueCOld = "c" + (i - 1);
-                               String valueDOld = "d" + (i - 1);
-
-                               IoTString iKeyAOld = new IoTString(keyAOld);
-                               IoTString iKeyBOld = new IoTString(keyBOld);
-                               IoTString iKeyCOld = new IoTString(keyCOld);
-                               IoTString iKeyDOld = new IoTString(keyDOld);
-                               IoTString iValueAOld = new IoTString(valueAOld);
-                               IoTString iValueBOld = new IoTString(valueBOld);
-                               IoTString iValueCOld = new IoTString(valueCOld);
-                               IoTString iValueDOld = new IoTString(valueDOld);
+                       if ((testValB2 != null)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyB);
+                               foundError = true;
+                       }
+               }
 
-                               t1.startTransaction();
-                               t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyAOld, iValueAOld, Guard.Equal))));
-                               t1.addKV(iKeyA, iValueA);
-                               t1.commitTransaction();
+               for (int t = 0; t < NUMBER_OF_TESTS; t++) {
+                       for (int i = 0; i < 4; i++) {
+                               String keyC = "c" + i;
+                               String valueC = "c" + (i + t);
 
-                               t1.startTransaction();
-                               t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyBOld, iValueBOld, Guard.Equal))));
-                               t1.addKV(iKeyB, iValueB);
-                               t1.commitTransaction();
+                               IoTString iKeyC = new IoTString(keyC);
+                               IoTString iValueC = new IoTString(valueC);
 
                                t2.startTransaction();
-                               t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyCOld, iValueCOld, Guard.Equal))));
                                t2.addKV(iKeyC, iValueC);
-                               t2.commitTransaction();
+                               transStatusList.add(t2.commitTransaction());
+                       }
+               }
 
-                               t2.startTransaction();
-                               t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyDOld, iValueDOld, Guard.Equal))));
-                               t2.addKV(iKeyD, iValueD);
-                               t2.commitTransaction();
+               for (int i = 0; i < 4; i++) {
+                       String keyC = "c" + i;
+                       String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
+                       IoTString iKeyC = new IoTString(keyC);
+                       IoTString iValueC = new IoTString(valueC);
 
+                       IoTString testValC1 = t1.getSpeculative(iKeyC);
+                       IoTString testValC2 = t2.getSpeculative(iKeyC);
 
-                       } else {
-                               t1.startTransaction();
-                               t1.addKV(iKeyA, iValueA);
-                               t1.commitTransaction();
+                       if ((testValC1 != null)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyC + "   " + testValC1);
+                               foundError = true;
+                       }
 
-                               t1.startTransaction();
-                               t1.addKV(iKeyB, iValueB);
-                               t1.commitTransaction();
+                       if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyC + "   " + testValC2);
+                               foundError = true;
+                       }
+               }
 
-                               t2.startTransaction();
-                               t2.addKV(iKeyC, iValueC);
-                               t2.commitTransaction();
+               for (int t = 0; t < NUMBER_OF_TESTS; t++) {
+                       for (int i = 0; i < 4; i++) {
+                               String keyA = "a" + i;
+                               String keyD = "d" + i;
+                               String valueA = "a" + (i + t);
+                               String valueD = "d" + (i + t);
+
+                               IoTString iKeyA = new IoTString(keyA);
+                               IoTString iKeyD = new IoTString(keyD);
+                               IoTString iValueA = new IoTString(valueA);
+                               IoTString iValueD = new IoTString(valueD);
+
+                               t1.startTransaction();
+                               t1.addKV(iKeyA, iValueA);
+                               transStatusList.add(t1.commitTransaction());
 
                                t2.startTransaction();
                                t2.addKV(iKeyD, iValueD);
-                               t2.commitTransaction();
+                               transStatusList.add(t2.commitTransaction());
                        }
                }
-               endTime = System.currentTimeMillis();
-
-               System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
-               System.out.println("Time Taken Per Update: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
-               System.out.println();
-
 
                System.out.println("Updating Clients...");
                t1.update();
                t2.update();
-               t1.update();
-               t2.update();
 
-               boolean foundError = false;
 
                System.out.println("Checking Key-Values...");
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+               for (int i = 0; i < 4; i++) {
 
                        String keyA = "a" + i;
                        String keyB = "b" + i;
                        String keyC = "c" + i;
                        String keyD = "d" + i;
-                       String valueA = "a" + i;
-                       String valueB = "b" + i;
-                       String valueC = "c" + i;
-                       String valueD = "d" + i;
+                       String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
+                       String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
+                       String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
+                       String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
 
                        IoTString iKeyA = new IoTString(keyA);
                        IoTString iKeyB = new IoTString(keyB);
@@ -1069,22 +1292,22 @@ public class Test {
                        IoTString testValD2 = t2.getCommitted(iKeyD);
 
                        if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
-                               System.out.println("Key-Value t1 incorrect: " + keyA);
+                               System.out.println("Key-Value t1 incorrect: " + keyA + "    " + testValA1);
                                foundError = true;
                        }
 
                        if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
-                               System.out.println("Key-Value t1 incorrect: " + keyB);
+                               System.out.println("Key-Value t1 incorrect: " + keyB + "    " + testValB1);
                                foundError = true;
                        }
 
                        if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
-                               System.out.println("Key-Value t1 incorrect: " + keyC);
+                               System.out.println("Key-Value t1 incorrect: " + keyC + "    " + testValC1);
                                foundError = true;
                        }
 
                        if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
-                               System.out.println("Key-Value t1 incorrect: " + keyD);
+                               System.out.println("Key-Value t1 incorrect: " + keyD + "    " + testValD1);
                                foundError = true;
                        }
 
@@ -1110,6 +1333,12 @@ public class Test {
                        }
                }
 
+               for (TransactionStatus status : transStatusList) {
+                       if (status.getStatus() != TransactionStatus.StatusCommitted) {
+                               foundError = true;
+                       }
+               }
+
                if (foundError) {
                        System.out.println("Found Errors...");
                } else {
@@ -1117,18 +1346,19 @@ public class Test {
                }
        }
 
-       static void test4() {
+       static void test4() throws ServerException, InterruptedException {
 
+               boolean foundError = false;
                long startTime = 0;
                long endTime = 0;
+               List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
 
                // Setup the 2 clients
-               Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
                t1.initTable();
-               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
                t2.update();
 
-
                // Make the Keys
                System.out.println("Setting up keys");
                startTime = System.currentTimeMillis();
@@ -1147,9 +1377,6 @@ public class Test {
                        t2.createNewKey(id, 351);
                }
                endTime = System.currentTimeMillis();
-
-
-
                System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
                System.out.println("Time Taken Per Key: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
                System.out.println();
@@ -1180,35 +1407,31 @@ public class Test {
 
                                t1.startTransaction();
                                t1.addKV(iKeyA, iValueA);
-                               t1.commitTransaction();
+                               transStatusList.add(t1.commitTransaction());
 
                                t1.startTransaction();
                                t1.addKV(iKeyB, iValueB);
-                               t1.commitTransaction();
+                               transStatusList.add(t1.commitTransaction());
 
                                t2.startTransaction();
                                t2.addKV(iKeyC, iValueC);
-                               t2.commitTransaction();
+                               transStatusList.add(t2.commitTransaction());
 
                                t2.startTransaction();
                                t2.addKV(iKeyD, iValueD);
-                               t2.commitTransaction();
+                               transStatusList.add(t2.commitTransaction());
                        }
                }
                endTime = System.currentTimeMillis();
-
                System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
-               System.out.println("Time Taken Per Update: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 8))   );
+               System.out.println("Time Taken Per Update: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 16))   );
                System.out.println();
 
 
                System.out.println("Updating Clients...");
                t1.update();
                t2.update();
-               t1.update();
-               t2.update();
 
-               boolean foundError = false;
 
                System.out.println("Checking Key-Values...");
                for (int i = 0; i < 4; i++) {
@@ -1284,6 +1507,12 @@ public class Test {
                        }
                }
 
+               for (TransactionStatus status : transStatusList) {
+                       if (status.getStatus() != TransactionStatus.StatusCommitted) {
+                               foundError = true;
+                       }
+               }
+
                if (foundError) {
                        System.out.println("Found Errors...");
                } else {
@@ -1291,15 +1520,18 @@ public class Test {
                }
        }
 
-       static void test3() {
+       static void test3() throws ServerException, InterruptedException {
 
                long startTime = 0;
                long endTime = 0;
+               boolean foundError = false;
+
+               List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
 
                // Setup the 2 clients
-               Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
                t1.initTable();
-               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
                t2.update();
 
 
@@ -1321,9 +1553,6 @@ public class Test {
                        t2.createNewKey(id, 351);
                }
                endTime = System.currentTimeMillis();
-
-
-
                System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
                System.out.println("Time Taken Per Key: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
                System.out.println();
@@ -1341,7 +1570,7 @@ public class Test {
 
                        t1.startTransaction();
                        t1.addKV(iKeyB, iValueB);
-                       t1.commitTransaction();
+                       transStatusList.add(t1.commitTransaction());
                }
 
                for (int i = 0; i < NUMBER_OF_TESTS; i++) {
@@ -1353,7 +1582,7 @@ public class Test {
 
                        t2.startTransaction();
                        t2.addKV(iKeyC, iValueC);
-                       t2.commitTransaction();
+                       transStatusList.add(t2.commitTransaction());
                }
 
                for (int i = 0; i < NUMBER_OF_TESTS; i++) {
@@ -1369,14 +1598,13 @@ public class Test {
 
                        t1.startTransaction();
                        t1.addKV(iKeyA, iValueA);
-                       t1.commitTransaction();
+                       transStatusList.add(t1.commitTransaction());
 
                        t2.startTransaction();
                        t2.addKV(iKeyD, iValueD);
-                       t2.commitTransaction();
+                       transStatusList.add(t2.commitTransaction());
                }
                endTime = System.currentTimeMillis();
-
                System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
                System.out.println("Time Taken Per Update: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
                System.out.println();
@@ -1385,10 +1613,7 @@ public class Test {
                System.out.println("Updating Clients...");
                t1.update();
                t2.update();
-               t1.update();
-               t2.update();
 
-               boolean foundError = false;
 
                System.out.println("Checking Key-Values...");
                for (int i = 0; i < NUMBER_OF_TESTS; i++) {
@@ -1464,6 +1689,12 @@ public class Test {
                        }
                }
 
+               for (TransactionStatus status : transStatusList) {
+                       if (status.getStatus() != TransactionStatus.StatusCommitted) {
+                               foundError = true;
+                       }
+               }
+
                if (foundError) {
                        System.out.println("Found Errors...");
                } else {
@@ -1471,21 +1702,21 @@ public class Test {
                }
        }
 
-       static void test2() {
+       static void test2() throws ServerException, InterruptedException {
 
+               boolean foundError = false;
                long startTime = 0;
                long endTime = 0;
+               List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
 
                // Setup the 2 clients
-               Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
                t1.initTable();
-               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
-               t2.update();
-
-               // t1.rebuild();
-               // t2.rebuild();
-
+               System.out.println("T1 Ready");
 
+               Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               t2.update();
+               System.out.println("T2 Ready");
 
                // Make the Keys
                System.out.println("Setting up keys");
@@ -1505,14 +1736,10 @@ public class Test {
                        t2.createNewKey(id, 351);
                }
                endTime = System.currentTimeMillis();
-
-
-
                System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
                System.out.println("Time Taken Per Key: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
                System.out.println();
 
-
                // Do Updates for the keys
                System.out.println("Setting Key-Values...");
                startTime = System.currentTimeMillis();
@@ -1537,22 +1764,21 @@ public class Test {
 
                        t1.startTransaction();
                        t1.addKV(iKeyA, iValueA);
-                       t1.commitTransaction();
+                       transStatusList.add(t1.commitTransaction());
 
                        t1.startTransaction();
                        t1.addKV(iKeyB, iValueB);
-                       t1.commitTransaction();
+                       transStatusList.add(t1.commitTransaction());
 
                        t2.startTransaction();
                        t2.addKV(iKeyC, iValueC);
-                       t2.commitTransaction();
+                       transStatusList.add(t2.commitTransaction());
 
                        t2.startTransaction();
                        t2.addKV(iKeyD, iValueD);
-                       t2.commitTransaction();
+                       transStatusList.add(t2.commitTransaction());
                }
                endTime = System.currentTimeMillis();
-
                System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
                System.out.println("Time Taken Per Update: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
                System.out.println();
@@ -1561,10 +1787,7 @@ public class Test {
                System.out.println("Updating Clients...");
                t1.update();
                t2.update();
-               t1.update();
-               t2.update();
 
-               boolean foundError = false;
 
                System.out.println("Checking Key-Values...");
                for (int i = 0; i < NUMBER_OF_TESTS; i++) {
@@ -1640,6 +1863,12 @@ public class Test {
                        }
                }
 
+               for (TransactionStatus status : transStatusList) {
+                       if (status.getStatus() != TransactionStatus.StatusCommitted) {
+                               foundError = true;
+                       }
+               }
+
                if (foundError) {
                        System.out.println("Found Errors...");
                } else {