Rewrote limited rewrapping to cover more corner cases

Added three tests, too:
The first catches a corner case where the buffer wasn't flushed before a
short string when there were only two lines.

The second exercises the algorithm generally on a larger piece of text
including multiple changes to the quoting level.

The third verifies its behaviour on single long lines.

I have some notes for other possible tests, but I'm not honestly sure if
they're necessary or not.