utils/stdcopy: fix hang in StdCopy

Also added some automated tests. I will check whether we can import this
kind of stuff from Dockcer again. I expect more stability now that
they've released the 1.0 version.

Fix #114.