Fix failing test on mono

Mono implementation of SynchronizedStream is buggy
https://bugzilla.xamarin.com/show_bug.cgi?id=25498
This patch is a workaround.

It also fixes build without nuget restore

Change-Id: Idcd2965525bcfd197c5cdabe2ddec74e86750158