I've discovered an alternative implementation in AdvancedJoiners#QueryJoin#JoinLines() that considered some corner cases that this one would not handle, but the overall implementation is cleaner (and newer) in here. Therefore, add test coverage and port the fixes over to here, and make it correct.