all tests seem to be integrated and working
diff --git a/QCBOR.xcodeproj/project.pbxproj b/QCBOR.xcodeproj/project.pbxproj
index 7dd2403..6375f48 100644
--- a/QCBOR.xcodeproj/project.pbxproj
+++ b/QCBOR.xcodeproj/project.pbxproj
@@ -35,7 +35,7 @@
 
 /* Begin PBXFileReference section */
 		0F58EB9B216A388E002FD6D1 /* qcbor_decode_malloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = qcbor_decode_malloc.c; path = src/qcbor_decode_malloc.c; sourceTree = "<group>"; };
-		0FA9BEB5216CE6CA00BA646B /* qcbor_decode_tests.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = qcbor_decode_tests.c; path = test/qcbor_decode_tests.c; sourceTree = "<group>"; };
+		0FA9BEB5216CE6CA00BA646B /* qcbor_decode_tests.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.c; name = qcbor_decode_tests.c; path = test/qcbor_decode_tests.c; sourceTree = "<group>"; tabWidth = 3; };
 		0FA9BEB6216CE6CA00BA646B /* qcbor_decode_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = qcbor_decode_tests.h; path = test/qcbor_decode_tests.h; sourceTree = "<group>"; };
 		0FA9BEB8216DC7AD00BA646B /* qcbor_encode_tests.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.c; name = qcbor_encode_tests.c; path = test/qcbor_encode_tests.c; sourceTree = "<group>"; tabWidth = 3; };
 		0FA9BEB9216DC7AD00BA646B /* qcbor_encode_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = qcbor_encode_tests.h; path = test/qcbor_encode_tests.h; sourceTree = "<group>"; };
@@ -319,7 +319,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				CODE_SIGN_STYLE = Automatic;
-				GCC_OPTIMIZATION_LEVEL = s;
+				GCC_OPTIMIZATION_LEVEL = 0;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 			};
 			name = Debug;
@@ -328,7 +328,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				CODE_SIGN_STYLE = Automatic;
-				GCC_OPTIMIZATION_LEVEL = s;
+				GCC_OPTIMIZATION_LEVEL = 0;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 			};
 			name = Release;
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index 778bca9..e8eca35 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -448,10 +448,7 @@
 
 /* 
    Tests the decoding of lots of different integers sizes 
-   and values.  
- 
-   Todo: test values 254, 255 and 256
- 
+   and values.
  */
 
 int IntegerValuesParseTest()
@@ -834,32 +831,39 @@
 
 /*
  This test parses pValidMapEncoded and checks for extra bytes along the way
- // TODO: this test doesn't work the same way... what to do do
- // The error handling is different because of the way Finish works.
  */
-static int ExtraBytesTest()
+static int ExtraBytesTest(int nLevel)
 {
    QCBORDecodeContext DCtx;
    QCBORItem Item;
    int nCBORError;
    
-   
    QCBORDecode_Init(&DCtx, (UsefulBufC){pValidMapEncoded, sizeof(pValidMapEncoded)}, QCBOR_DECODE_MODE_NORMAL);
    
-   if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_EXTRA_BYTES) {
-      return -1;
+   if(nLevel < 1) {
+      if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_EXTRA_BYTES) {
+         return -1;
+      } else {
+         return 0;
+      }
    }
    
+   
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
       return nCBORError;
    if(Item.uDataType != QCBOR_TYPE_MAP ||
       Item.val.uCount != 3)
       return -1;
 
-   if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN) {
-      return -1;
+   if(nLevel < 2) {
+      if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN) {
+         return -1;
+      } else {
+         return 0;
+      }
    }
    
+   
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
       return nCBORError;
    if(Item.uLabelType != QCBOR_TYPE_TEXT_STRING ||
@@ -869,8 +873,12 @@
       memcmp(Item.label.string.ptr, "first integer", 13))
       return -1;
    
-   if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_EXTRA_BYTES) {
-      return -1;
+   if(nLevel < 3) {
+      if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN) {
+         return -1;
+      } else {
+         return 0;
+      }
    }
    
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
@@ -882,8 +890,13 @@
       Item.val.uCount != 2)
       return -1;
    
-   if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_EXTRA_BYTES) {
-      return -1;
+   
+   if(nLevel < 4) {
+      if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN) {
+         return -1;
+      } else {
+         return 0;
+      }
    }
    
    
@@ -894,8 +907,12 @@
       memcmp(Item.val.string.ptr, "string1", 7))
       return -1;
    
-   if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_EXTRA_BYTES) {
-      return -1;
+   if(nLevel < 5) {
+      if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN) {
+         return -1;
+      } else {
+         return 0;
+      }
    }
    
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
@@ -905,8 +922,12 @@
       memcmp(Item.val.string.ptr, "string2", 7))
       return -1;
  
-   if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_EXTRA_BYTES) {
-      return -1;
+   if(nLevel < 6) {
+      if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN) {
+         return -1;
+      } else {
+         return 0;
+      }
    }
    
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
@@ -918,8 +939,12 @@
       Item.val.uCount != 4)
       return -1;
    
-   if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_EXTRA_BYTES) {
-      return -1;
+   if(nLevel < 7) {
+      if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN) {
+         return -1;
+      } else {
+         return 0;
+      }
    }
    
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
@@ -932,8 +957,12 @@
       memcmp(Item.val.string.ptr, "xxxx", 4))
       return -1;
    
-   if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_EXTRA_BYTES) {
-      return -1;
+   if(nLevel < 8) {
+      if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN) {
+         return -1;
+      } else {
+         return 0;
+      }
    }
    
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
@@ -946,8 +975,12 @@
       memcmp(Item.val.string.ptr, "yyyy", 4))
       return -1;
    
-   if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_EXTRA_BYTES) {
-      return -1;
+   if(nLevel < 9) {
+      if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN) {
+         return -1;
+      } else {
+         return 0;
+      }
    }
    
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
@@ -959,8 +992,12 @@
       Item.val.int64 != 98)
       return -1;
    
-   if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_EXTRA_BYTES) {
-      return -1;
+   if(nLevel < 10) {
+      if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN) {
+         return -1;
+      } else {
+         return 0;
+      }
    }
    
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
@@ -985,10 +1022,15 @@
 
 int ParseMapTest()
 {
-   int n = ParseMapTest1();
+   int n = ParseMapTest1();  // TODO: review this test carefully
    
    if(!n) {
-      n = ExtraBytesTest();
+      for(int i = 0; i < 10; i++) {
+         n = ExtraBytesTest(i);
+         if(n) {
+            break;
+         }
+      }
    }
    
    return(n);
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index ae94a7f..3636ba4 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -80,7 +80,6 @@
    fflush(stdout);
 }
 
-#endif
 
 #include <stdio.h>
 
@@ -95,13 +94,15 @@
    return 0;
    
 }
+#endif
 
 
-/*#define CheckResults(Enc, Expected) \
-   UsefulBuf_Compare(Enc, (UsefulBufC){Expected, sizeof(Expected)}) */
 
 #define CheckResults(Enc, Expected) \
-   Compare(Enc, (UsefulBufC){Expected, sizeof(Expected)})
+   UsefulBuf_Compare(Enc, (UsefulBufC){Expected, sizeof(Expected)})
+
+//#define CheckResults(Enc, Expected) \
+//   Compare(Enc, (UsefulBufC){Expected, sizeof(Expected)})
 
 
 
@@ -899,7 +900,6 @@
    }
    size_t nEncodedLen;
    if(QCBOREncode_Finish(&ECtx, &nEncodedLen)) {
-      printf("ArrayNestingTest1 Failed\n");
       nReturn = -1;
    }
    //printencoded(pEncoded, nEncodedLen);
@@ -958,43 +958,9 @@
    return(nReturn);
 }
 
-#if 0
-
 
 static uint8_t s_pFiveArrarys[] = {0x81, 0x81, 0x81, 0x81, 0x80};
 
-static int EncodeRaw(uint8_t **pEncoded, size_t *pEncodedLen)
-{
-   QCBOREncodeContext ECtx;
-   int nReturn = -1;
-   
-   *pEncoded = NULL;
-   *pEncodedLen = INT32_MAX; // largest buffer this CBOR implementation will deal with
-   
-   // loop runs CBOR encoding twice. First with no buffer to
-   // calucate the length so buffer can be allocated correctly,
-   // and last with the buffer to do the actual encoding
-   do {
-      QCBOREncode_Init(&ECtx, *pEncoded, *pEncodedLen);
-      QCBOREncode_OpenArray(&ECtx);
-      QCBOREncode_AddRaw(&ECtx, (EncodedCBORC){((UsefulBufC) {s_pFiveArrarys, 5}), 1});
-      QCBOREncode_AddRaw(&ECtx, (EncodedCBORC){((UsefulBufC) {pExpectedEncodedInts, sizeof(pExpectedEncodedInts)}), 1});
-      QCBOREncode_CloseArray(&ECtx);
-      
-      if(QCBOREncode_Finish(&ECtx, pEncodedLen))
-         goto Done;
-      if(*pEncoded != NULL) {
-         nReturn = 0;
-         goto Done;
-      }
-      *pEncoded = malloc(*pEncodedLen);
-   } while(1);
-   
-Done:
-   return(nReturn);
-}
-
-
 // Validated at http://cbor.me and by manually examining its output
 static uint8_t s_pEncodeRawExpected[] = {
    0x82, 0x81, 0x81, 0x81, 0x81, 0x80, 0x98, 0x2f,
@@ -1023,26 +989,31 @@
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
 
-
 int EncodeRawTest()
 {
-   uint8_t *pEncodedRaw;
-   size_t nEncodedRawLen;
+   UsefulBuf_MakeStackUB(RawTestStorage, 220);
    
-   if(EncodeRaw(&pEncodedRaw, &nEncodedRawLen)) {
-      return(-1);
+   QCBOREncodeContext ECtx;
+
+   QCBOREncode_Init(&ECtx, RawTestStorage);
+   QCBOREncode_OpenArray(&ECtx);
+   QCBOREncode_AddEncoded(&ECtx, UsefulBuf_FromByteArrayLiteral(s_pFiveArrarys));
+   QCBOREncode_AddEncoded(&ECtx, UsefulBuf_FromByteArrayLiteral(pExpectedEncodedInts));
+   QCBOREncode_CloseArray(&ECtx);
+   
+   UsefulBufC EncodedRawTest;
+   
+   if(QCBOREncode_Finish2(&ECtx, &EncodedRawTest)) {
+      return -4;
    }
    
-   //printencoded(pEncodedRaw, nEncodedRawLen);
+   if(UsefulBuf_Compare(EncodedRawTest, UsefulBuf_FromByteArrayLiteral(s_pEncodeRawExpected))) {
+      return -5;
+   }
    
-  int nReturn = 0;
-  if(nEncodedRawLen != sizeof(s_pEncodeRawExpected) ||  memcmp(s_pEncodeRawExpected, pEncodedRaw, sizeof(s_pEncodeRawExpected)))
-      nReturn = 1;
-   
-   return(nReturn);
+   return 0;
 }
 
-#endif
 
 
 
diff --git a/test/run_tests.c b/test/run_tests.c
index ed58746..6b5b736 100644
--- a/test/run_tests.c
+++ b/test/run_tests.c
@@ -112,6 +112,7 @@
 
 
 test_entry s_tests[] = {
+    TEST_ENTRY(EncodeRawTest),
     TEST_ENTRY(FloatValuesTest1),
     TEST_ENTRY(RTICResultsTest),
     TEST_ENTRY(MapEncodeTest),