   }
 
   func testPublishFailure() {
-    let expectation = self.expectationWithDescription("publish success")
-
     let client = MockClient(deviceKey: "some-key", expectedState: .DISCONNECTED)
     successMock()
-    client.connect() { _ in
-      do {
-        XCTAssertThrowsError(try client.publishOn("data", message: "Hello"))
-      } catch {}
+    XCTAssertThrowsError(try client.publishOn("data", message: "Hello"))
+  }
+
+  func testSubscribeSuccess() {
+    let expectation = self.expectationWithDescription("subscribe success")
+
+    let client = MockClient(deviceKey: "some-key", expectedState: .CONNECTED)
+    successMock()
+    client.connect() { _ in
+      try! client.subscribe(nil)
       if let mqtt = client.mqttClient as? MockMQTTClient {
-        XCTAssertFalse(mqtt.didPublish)
+        XCTAssertTrue(mqtt.isSubscribed)
       }
       expectation.fulfill()
     }
     self.waitForExpectationsWithTimeout(0.5, handler: nil)
+  }
+
+  func testSubscribeFailure() {
+    let client = MockClient(deviceKey: "some-key", expectedState: .DISCONNECTED)
+    successMock()
+    XCTAssertThrowsError(try client.subscribe(nil))
+  }
+
+  func testUnsubscribeSuccess() {
+    let expectation = self.expectationWithDescription("subscribe success")
+
+    let client = MockClient(deviceKey: "some-key", expectedState: .CONNECTED)
+    successMock()
+    client.connect() { _ in
+      try! client.subscribe(nil)
+      try! client.unsubscribe()
+      if let mqtt = client.mqttClient as? MockMQTTClient {
+        XCTAssertFalse(mqtt.isSubscribed)
+      }
+      expectation.fulfill()
+    }
+    self.waitForExpectationsWithTimeout(0.5, handler: nil)
+  }
+
+  func testUnsubscribeFailure() {
+    let client = MockClient(deviceKey: "some-key", expectedState: .DISCONNECTED)
+    successMock()
+    XCTAssertThrowsError(try client.unsubscribe())
   }
 
 }

    let expectation = self.expectationWithDescription("fetch config")

    malformedResponseMock()
    let client = MockClient(deviceKey: "some-key", endpointScheme: "", endpointUrl: "garbage", endpointPort: nil)
    client.connect() { error in
      XCTAssertNotNil(error)
      expectation.fulfill()


  var expectedState = CocoaMQTTConnState.CONNECTED
  internal var didPublish = false
  internal var isSubscribed = false

  init(expectedState state: CocoaMQTTConnState) {
    expectedState = state
