 }
 
 extension NetworkStatusParameters {
-    
+
     static let allValues = [bluetooth, bluetoothLowEnergy, wifi, cellular, bssid]
 }
 
 struct Constants {
-    
+
     struct TimeForWhich {
-        
+
         static let  bluetoothStateIsChanged: NSTimeInterval = 10
     }
-    
+
     struct NSNotificationName {
-        
+
         static let centralBluetoothManagerDidChangeState = "CentralBluetoothManagerDidChangeState"
     }
 }
 
 private extension Selector {
-    
+
     static let centralBluetoothManagerStateChanged =
         #selector(AppContextTests.centralBluetoothManagerStateChanged(_:))
 }
 
 enum BluetoothHardwareState: String {
-    
+
     case on = "on"
     case off = "off"
 }

        }
        XCTAssertEqual(contextError, .badParameters)
    }
    
    func testGetIOSVersion() {
        XCTAssertEqual(NSProcessInfo().operatingSystemVersionString, context.getIOSVersion())
    }
    
    func testThaliCoreErrors() {
        // testing parameters count
        context.multiConnectToPeer([""]) {
            guard let err = $0 as? AppContextError else {
                XCTFail("unexpected error \($0)")
                return
            }
            XCTAssertEqual(err, AppContextError.badParameters)
        }
        // testing parameter types
        context.multiConnectToPeer([2, 2]) {
            guard let err = $0 as? AppContextError else {
                XCTFail("unexpected error \($0)")
                return
            }
            XCTAssertEqual(err, AppContextError.badParameters)
        }
    }
    
    func testMultiConnect() {
        // todo will be implemented as soon as we will have the whole stack working #881
    }
    
    func testErrorDescription() {
        XCTAssertEqual(ThaliCoreError.IllegalPeerID.rawValue,
                       errorDescription(ThaliCoreError.IllegalPeerID))
        
        let unknownError = AppContextError.unknownError
        XCTAssertEqual((unknownError as NSError).localizedDescription,
                       errorDescription(unknownError))
    }
    
    func testJsonValue() {
        var jsonDict: [String : AnyObject] = ["number" : 4.2]
        var jsonString = "{\"number\":4.2}"


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