Six of my other pull requests merged together

This is a merge of #189, #192, #197, #206, #248 and #241.
As such, it closes #131, #247 and #224.

The main reason for merging these is to apply the benefits of #241 to the tests added by the other pullreqs - the results are shorter and more compact. A number of small conflicts between them are also resolved.