Fix distanceTo function when both line segments are on the same plane (issue #1391). Add associated unit tests.