protected override void ActMethod() { removedInstanceSink = null; GC.Collect(); // test failed intermittently without the delay, garbage collection message was missing. Task.Delay(TimeSpan.FromMilliseconds(1)).Wait(); source.DoIt(); Trace.Flush(); memoryStream.Position = 0; string text; using (var reader = new StreamReader(memoryStream)) { text = reader.ReadToEnd(); } traceLines.AddRange(text.Split("\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)); }