When I ported UMS, I noticed a bug in code lines that copy memory. I fixed the bug in Write, but not in Read (because tests were not working properly). This commit fixes the bug in Read and fixes tests to be more robust.
Also, opportunistically, I changed some visibilities from internal to private.
Commit migrated from https://github.com/dotnet/corefx/commit/3e383668c1b147cc9e22982e34203a221ce6be4d
TaskHelpers.cs is a temporary stop-gap for assemblies that don't yet depend on the latest System.Threading.Tasks contract. This change removes the dependency for those assemblies that do, changing them to use the Task.CompletedTask, Task.FromCanceled, and Task.FromException members on Task instead of the corresponding workarounds on TaskHelpers. This file should eventually go away entirely.
Commit migrated from https://github.com/dotnet/corefx/commit/325e24de73b86c2b1f920109afe06faedb42b3d8