     XCTAssert(r2.value == nil)
     XCTAssert(r2.error as? TestError == TestError.Error(value))
 
-    let badres = Result<Double>.Error(TestError.Error(error))
+    let badres: Result<Double> = nil
 
     // Bad operand, transform not used
     let r3 = badres.map { (d: Double) throws -> Int in XCTFail(); return 0 }
     XCTAssert(r3.value == nil)
-    XCTAssert(r3.error as? TestError == TestError.Error(error))
+    XCTAssert(r3.error != nil)
   }
 
   func testFlatMap()
   {
     let value = arc4random()
-    let error = arc4random()
     let goodres = Result.Value(value)
 
     // Good operand, good transform

  func testMap()
  {
    let value = arc4random()
    let error = arc4random()
    let goodres = Result.Value(value)

    // Good operand, good transform

    XCTAssert(r2.value == nil)
    XCTAssert(r2.error as? TestError == TestError.Error(value))

    let badres: Result<Double> = nil

    // Bad operand, transform not used
    let r3 = badres.flatMap { _ in Result<String> { XCTFail(); return "" } }
    XCTAssert(r3.value == nil)
    XCTAssert(r3.error != nil)
  }

  func testApply()
