documenting Config.Extend

I have tried to hide the messy ByteString conversions which was
obscuring the meaning of the doctests inside a helper function.

Writing the tests first also allowed me to find (and fix) a bug in our
calculations of the LINE pragmas, which is kind of what tests are for.