 
         }
         var once = false
-        s.onDisconnect = {[unowned self] (error: NSError?) in
+        s.onDisconnect = { [weak self, weak s]  (error: NSError?) in
             if !once {
                 once = true
-                self.runTest(caseNum)
+                self?.runTest(caseNum)
             }
-            self.removeSocket(s)
+            self?.removeSocket(s)
         }
         s.connect()
     }

    func getTestInfo(_ caseNum: Int) {
        let s = createSocket("getCaseInfo",caseNum)
        socketArray.append(s)
        s.onText = {(text: String) in
//            let data = text.dataUsingEncoding(NSUTF8StringEncoding)
//            do {
//                let resp: AnyObject? = try NSJSONSerialization.JSONObjectWithData(data!,

    func verifyTest(_ caseNum: Int) {
        let s = createSocket("getCaseStatus",caseNum)
        self.socketArray.append(s)
        s.onText = { (text: String) in
            let data = text.data(using: String.Encoding.utf8)
            do {
                let resp: Any? = try JSONSerialization.jsonObject(with: data!,
