         return newSpan
     }
 
-    func endSpanAndValidateContext(span: Span, parentSpan: Span) {
+    func endSpanAndValidateContext(span: Span, parentSpan: Span?) {
         var activeSpan = ActivityContextManager.instance.getCurrentContextValue(forKey: .span)
         XCTAssert(activeSpan === span)
         span.end()

        }

        @available(macOS 10.15, iOS 13.0, tvOS 13.0, *)
        func testStartAndEndSpanInAsyncTaskDetachedWithParent() {
            XCTExpectFailure()
            let span1 = defaultTracer.spanBuilder(spanName: "testStartAndEndSpanInAsyncTask1").startSpan()
            ActivityContextManager.instance.setCurrentContextValue(forKey: .span, value: span1)
            let expec = expectation(description: "testStartAndEndSpanInAsyncTaskWithParent")
            Task.detached {
                XCTAssert(ActivityContextManager.instance.getCurrentContextValue(forKey: .span) === span1)
                await self.createAsyncSpan(parentSpan: span1)
                XCTAssert(OpenTelemetry.instance.contextProvider.activeSpan === span1)
                expec.fulfill()
            }
            span1.end()

        }

        @available(macOS 10.15, iOS 13.0, tvOS 13.0, *)
        // First created task correctly inherits activity when created, so assigns the proper parent
        func testStartAndEndSpanInAsyncTaskWithParent() {
            let span1 = defaultTracer.spanBuilder(spanName: "testStartAndEndSpanInAsyncTask1").startSpan()
            ActivityContextManager.instance.setCurrentContextValue(forKey: .span, value: span1)
            let expec = expectation(description: "testStartAndEndSpanInAsyncTaskWithParent")
