Fixed a number of typos in doc reported by eneftci

Also made sample code better PEP8-compliant, and fixed a minor typo in
an error message.

Fixes gh-1353
PEP8