Modify distance formula for multiple lines. Added testcase #3.