Revert "Revert "add test to verify buffered write failure""

This reverts commit 748ac813cf0706890b28dddebdf04ee32630cb9b.
Revert "fix compile error using {{make -k check}} in OS X"

This reverts commit 63259c7ac74465e34473f74646be3ed0773645a3.