V4: fix range splitting when split is between intervals.

Also added some "white-box" unit tests and sprinkled in a bit of
documentation. The case that went wrong is covered by the test
rangeSplitting_1: before the fix, the new interval would have
two ranges: [66-64],[70-71]. The first range is invalid and should not
be there at all.

Change-Id: If0742f4e6a96d98ea5d696f95126886ba66f92bb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Merge remote-tracking branch 'origin/stable' into dev

Change-Id: Id265682aa7db9be1c0b305ab3207b2c932a25a9f
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev