         validateAdvertisingUpdate(delegateMock.advertisingListeningState, advertising: true,
                                   browsing: false)
     }
-
+    
     func testListeningAdvertisingUpdateOnStartListening() {
         let delegateMock = AppContextDelegateMock(peerAvailabilityChangedHandler: { _ in
             XCTFail("unexpected peerAvailabilityChanged event")

    /// Network status represented as JSON String.
    /// Gets updated value in didChangeNetworkStatus method.
    var networkStatus: String?

    /// Indicates that didChangeNetworkStatus method was called at least once.
    var networkStatusUpdated = false

    /// Bluetooth RadioState value represented as String
    /// Gets updated value in didChangeNetworkStatus method.
    var bluetoothStateActual: String?

    /// BluetoothLowEnergy RadioState value represented as String
    /// Gets updated value in didChangeNetworkStatus method.
    var bluetoothLowEnergyStateActual: String?

    /// WiFi RadioState value represented as String
    /// Gets updated value in didChangeNetworkStatus method.
    var wifiStateActual: String?

    /// Cellular RadioState value represented as String
    /// Gets updated value in didChangeNetworkStatus method.
    var cellularStateActual: String?

    var advertisingListeningState = ""

    var willEnterBackground = false
    var didEnterForeground = false
    var discoveryUpdated = false

    let peerAvailabilityChangedHandler: (String) -> Void

    init(peerAvailabilityChangedHandler: (String) -> Void) {
        self.peerAvailabilityChangedHandler = peerAvailabilityChangedHandler
    }

    @objc func context(context: AppContext, didResolveMultiConnectWithSyncValue value: String,
                           error: NSObject?, listeningPort: NSObject?) {}
    @objc func context(context: AppContext,
                       didFailMultiConnectConnectionWith paramsJSONString: String) {}
    @objc func context(context: AppContext, didChangePeerAvailability peers: String) {


// 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
