Adding a check for gofmt and golint to tests

and fixing things accordingly to make `gofmt` and `golint` happy.  Please note that this required adding a fair number of comments, so I would appreciate a review of their accuracy