         jsonString = "{\"bool\":true}"
         XCTAssertEqual(jsonValue(jsonDict), jsonString)
     }
-    
+
     func testListeningAdvertisingUpdateOnStartAdvertising() {
         let delegateMock = AppContextDelegateMock(peerAvailabilityChangedHandler: { _ in
             XCTFail("unexpected peerAvailabilityChanged event")

    @objc func context(context: AppContext, didChangeNetworkStatus status: String) {
        networkStatusUpdated = true
        networkStatus = status
        
        bluetoothStateActual = nil
        bluetoothLowEnergyStateActual = nil
        wifiStateActual = nil
        cellularStateActual = nil
        
        if let dictinaryNetworkStatus = dictionaryValue(networkStatus!) {
            
            guard
                let bluetoothState =
                dictinaryNetworkStatus[NetworkStatusParameters.bluetooth.rawValue]


// MARK: - Test cases
class AppContextTests: XCTestCase {

    var context: AppContext! = nil

    weak var expectationThatPrivateBluetoothStateIsChanged: XCTestExpectation?
    weak var expectationThatCoreBluetoothStateIsChanged: XCTestExpectation?
    weak var expectationThatBothBluetoothStatesAreChanged: XCTestExpectation?
    var bluetoothChangingStateGroup: dispatch_group_t?

    override func setUp() {
        let serviceType = String.random(length: 8)
        context = AppContext(serviceType: serviceType)
    }

    override func tearDown() {
        context = nil
    }

    private func jsonDictionaryFrom(string: String) -> [String : AnyObject]? {
        guard let data = string.dataUsingEncoding(NSUTF8StringEncoding) else {
            return nil
