Index: src/Tesselation/BoundaryTriangleSet.cpp
===================================================================
--- src/Tesselation/BoundaryTriangleSet.cpp	(revision c27ce78e851407f0f868250263487f54ca132cde)
+++ src/Tesselation/BoundaryTriangleSet.cpp	(revision b92e4abd2c9d2269cf58be33cf7cd809f3e304bd)
@@ -230,52 +230,53 @@
   Vector Direction;
 
-  // 1. get intersection with plane
+  // 1. get intersection with plane and place in ClosestPoint
   LOG(1, "INFO: Looking for closest point of triangle " << *this << " to " << x << ".");
-  GetCenter(Direction);
+  LOG(1, "INFO: endpoints are " << endpoints[0]->node->getPosition() << ","
+      << endpoints[1]->node->getPosition() << ", and " << endpoints[2]->node->getPosition() << ".");
   try {
-    Line l = makeLineThrough(x, Direction);
-    ClosestPoint = Plane(NormalVector, (endpoints[0]->node->getPosition())).GetIntersection(l);
+    ClosestPoint = Plane(NormalVector, (endpoints[0]->node->getPosition())).getClosestPoint(x);
   }
   catch (LinearAlgebraException &excp) {
     (ClosestPoint) = (x);
   }
+  Vector InPlane(ClosestPoint); // points from plane intersection to straight-down point
 
   // 2. Calculate in plane part of line (x, intersection)
-  Vector InPlane = (x) - (ClosestPoint); // points from plane intersection to straight-down point
-  InPlane.ProjectOntoPlane(NormalVector);
-  InPlane += ClosestPoint;
-
-  LOG(2, "INFO: Triangle is " << *this << ".");
-  LOG(2, "INFO: Line is from " << Direction << " to " << x << ".");
-  LOG(2, "INFO: In-plane part is " << InPlane << ".");
+  LOG(2, "INFO: Closest point on triangle plane is " << ClosestPoint << ".");
 
   // Calculate cross point between one baseline and the desired point such that distance is shortest
-  double ShortestDistance = -1.;
-  bool InsideFlag = false;
   Vector CrossDirection[3];
   Vector CrossPoint[3];
-  Vector helper;
   for (int i = 0; i < 3; i++) {
-    // treat direction of line as normal of a (cut)plane and the desired point x as the plane offset, the intersect line with point
-    Direction = (endpoints[(i+1)%3]->node->getPosition()) - (endpoints[i%3]->node->getPosition());
+    const Vector Direction = (endpoints[i%3]->node->getPosition()) - (endpoints[(i+1)%3]->node->getPosition());
     // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal);
     Line l = makeLineThrough((endpoints[i%3]->node->getPosition()), (endpoints[(i+1)%3]->node->getPosition()));
-    CrossPoint[i] = Plane(Direction, InPlane).GetIntersection(l);
-    CrossDirection[i] = CrossPoint[i] - InPlane;
-    CrossPoint[i] -= (endpoints[i%3]->node->getPosition());  // cross point was returned as absolute vector
+    CrossPoint[i] = l.getClosestPoint(InPlane);
+    // NOTE: direction of line is normalized, hence s must not necessarily be in [0,1] for the baseline
+    LOG(2, "INFO: Closest point on line from " << (endpoints[(i+1)%3]->node->getPosition())
+        << " to " << (endpoints[i%3]->node->getPosition()) << " is " << CrossPoint[i] << ".");
+    CrossPoint[i] -= (endpoints[(i+1)%3]->node->getPosition());  // cross point was returned as absolute vector
     const double s = CrossPoint[i].ScalarProduct(Direction)/Direction.NormSquared();
     LOG(2, "INFO: Factor s is " << s << ".");
     if ((s >= -MYEPSILON) && ((s-1.) <= MYEPSILON)) {
-          CrossPoint[i] += (endpoints[i%3]->node->getPosition());  // make cross point absolute again
-      LOG(2, "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between " << endpoints[i % 3]->node->getPosition() << " and " << endpoints[(i + 1) % 3]->node->getPosition() << ".");
-      const double distance = CrossPoint[i].DistanceSquared(x);
-      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
-        ShortestDistance = distance;
-        (ClosestPoint) = CrossPoint[i];
-      }
-    } else
-      CrossPoint[i].Zero();
-  }
-  InsideFlag = true;
+      CrossPoint[i] += (endpoints[(i+1)%3]->node->getPosition());  // make cross point absolute again
+      LOG(2, "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between "
+          << endpoints[i % 3]->node->getPosition() << " and "
+          << endpoints[(i + 1) % 3]->node->getPosition() << ".");
+    } else {
+      // set to either endpoint of BoundaryLine
+      if (s < -MYEPSILON)
+        CrossPoint[i] = (endpoints[(i+1)%3]->node->getPosition());
+      else
+        CrossPoint[i] = (endpoints[i%3]->node->getPosition());
+      LOG(2, "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting outside of BoundaryLine between "
+          << endpoints[i % 3]->node->getPosition() << " and "
+          << endpoints[(i + 1) % 3]->node->getPosition() << ".");
+    }
+    CrossDirection[i] = CrossPoint[i] - InPlane;
+  }
+
+  bool InsideFlag = true;
+  double ShortestDistance = -1.;
   for (int i = 0; i < 3; i++) {
     const double sign = CrossDirection[i].ScalarProduct(CrossDirection[(i + 1) % 3]);
@@ -284,17 +285,17 @@
     if ((sign > -MYEPSILON) && (othersign > -MYEPSILON)) // have different sign
       InsideFlag = false;
-  }
+    // update current best candidate
+    const double distance = CrossPoint[i].DistanceSquared(x);
+    if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
+      ShortestDistance = distance;
+      (ClosestPoint) = CrossPoint[i];
+    }
+  }
+
   if (InsideFlag) {
     (ClosestPoint) = InPlane;
     ShortestDistance = InPlane.DistanceSquared(x);
-  } else { // also check endnodes
-    for (int i = 0; i < 3; i++) {
-      const double distance = x.DistanceSquared(endpoints[i]->node->getPosition());
-      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
-        ShortestDistance = distance;
-        (ClosestPoint) = (endpoints[i]->node->getPosition());
-      }
-    }
-  }
+  }
+
   LOG(1, "INFO: Closest Point is " << ClosestPoint << " with shortest squared distance is " << ShortestDistance << ".");
   return ShortestDistance;
Index: src/Tesselation/unittests/Makefile.am
===================================================================
--- src/Tesselation/unittests/Makefile.am	(revision c27ce78e851407f0f868250263487f54ca132cde)
+++ src/Tesselation/unittests/Makefile.am	(revision b92e4abd2c9d2269cf58be33cf7cd809f3e304bd)
@@ -14,7 +14,6 @@
 TESSELATIONTESTS = \
   TesselationUnitTest \
+  Tesselation_BoundaryTriangleUnitTest \
   Tesselation_InOutsideUnitTest
-
-XFAIL_TESTS += Tesselation_BoundaryTriangleUnitTest
 
 TESTS += $(TESSELATIONTESTS)
Index: src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp
===================================================================
--- src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp	(revision c27ce78e851407f0f868250263487f54ca132cde)
+++ src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp	(revision b92e4abd2c9d2269cf58be33cf7cd809f3e304bd)
@@ -218,6 +218,6 @@
     // failure is:Intersection (27.56537519896,13.40256646925,6.672946688134) is not inside triangle [702|Na5016,O6388,Na6498].
     // note that the Intersection cannot possibly lie be within the triangle!
-    const Vector testPoint();
-    const Vector testIntersection(27.56537519896,13.40256646925,6.672946688134);
+    // we test now against correct intersection
+    const Vector testIntersection(14.6872,36.204,39.8043);
     std::vector<Vector> vectors;
     vectors.push_back( Vector(10.7513,43.4247,48.4127) );
@@ -294,5 +294,7 @@
     // note that the Intersection cannot possibly lie be within the triangle
     // however, it is on its plane (off only by 2.7e-12)
+    // testPoint2 is corrected version
     const Vector testPoint(27.56537519896,13.40256646925,6.672946688134);
+    const Vector testPoint2(14.6872,36.204,39.8043);
     Vector testIntersection;
     std::vector<Vector> vectors;
@@ -302,5 +304,6 @@
     createTriangle(vectors);
     triangle->GetClosestPointInsideTriangle(testPoint, testIntersection);
-    CPPUNIT_ASSERT_EQUAL ( testPoint, testIntersection );
+    CPPUNIT_ASSERT ( testPoint != testIntersection );
+    CPPUNIT_ASSERT ( testPoint2 == testIntersection );
   }
 }
