Improve astropy.units test coverage

...and fix some small bugs discovered in the process.