0bfc2dde8f
This commit also includes a lot of useful tidying up of some of the unit test helper code. I turned out that I could not use all the helper code in my new tests, but despite that it will be useful in the future, so I am committing it here.