Fix a few resource leaks and prevent the test from hanging if an error occurs reading from the remote server. R=agl, gustav.paul, kardianos CC=golang-dev https://golang.org/cl/6423065