Index: src/Tesselation/ApproximateShapeArea.cpp
===================================================================
--- src/Tesselation/ApproximateShapeArea.cpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
+++ src/Tesselation/ApproximateShapeArea.cpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
@@ -0,0 +1,86 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * ApproximateShapeArea.cpp
+ *
+ *  Created on: Jan 30, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include <cmath>
+#include <set>
+#include <vector>
+
+#include "Atom/TesselPoint.hpp"
+#include "LinkedCell/PointCloudAdaptor.hpp"
+#include "ApproximateShapeArea.hpp"
+#include "Tesselation/tesselation.hpp"
+
+/** Constructor of class ApproximateShapeArea.
+ *
+ * @param _shape shape to calculate the surface area approximately
+ */
+ApproximateShapeArea::ApproximateShapeArea(const Shape &_shape) :
+		shape(_shape)
+{}
+
+/** Destructor of class ApproximateShapeArea.
+ *
+ */
+ApproximateShapeArea::~ApproximateShapeArea()
+{}
+
+/** Calculate the approximate surface area of the given \a shape.
+ *
+ * @return surface area approximated
+ */
+double ApproximateShapeArea::operator()() const
+{
+  const double distance = 2.;
+  const double min_area = distance*distance*distance;
+  const double radius = shape.getRadius();
+  const double surfacearea_upperbound = 4.*M_PI * radius*radius;
+  const size_t N = (int)(surfacearea_upperbound/min_area);
+  // get surface points
+  std::vector<Vector> SurfacePoints =
+      shape.getHomogeneousPointsOnSurface(N);
+  typedef std::set<TesselPoint *> NodeSet;
+  NodeSet SurfaceNodes;
+  for (size_t i=0;i<SurfacePoints.size();++i) {
+    TesselPoint * Walker = new TesselPoint();
+    Walker->setName(std::string("SurfaceNode")+toString(i));
+    Walker->setPosition(SurfacePoints[i]);
+    SurfaceNodes.insert(Walker);
+  }
+
+  // tesselate
+  PointCloudAdaptor<NodeSet> cloud(&SurfaceNodes, "TesselPointSTLList");
+  Tesselation *tesselator = new Tesselation;
+  (*tesselator)(cloud, distance);
+
+  // obtain surface area (assume angstroem)
+  const double surfacearea = tesselator->getAreaOfEnvelope(true);
+
+  // clear up
+  delete tesselator;
+  for (NodeSet::iterator iter = SurfaceNodes.begin();
+      !SurfaceNodes.empty(); iter = SurfaceNodes.begin()) {
+    delete *iter;
+    SurfaceNodes.erase(iter);
+  }
+
+  return surfacearea;
+}
+
Index: src/Tesselation/ApproximateShapeArea.hpp
===================================================================
--- src/Tesselation/ApproximateShapeArea.hpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
+++ src/Tesselation/ApproximateShapeArea.hpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
@@ -0,0 +1,36 @@
+/*
+ * ApproximateShapeArea.hpp
+ *
+ *  Created on: Jan 30, 2012
+ *      Author: heber
+ */
+
+#ifndef APPROXIMATESHAPEAREA_HPP_
+#define APPROXIMATESHAPEAREA_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Shapes/Shape.hpp"
+
+/** Functor for the approximate surface are of a shape.
+ *
+ * This class is just an intermediate until we have implemented a better way
+ * to calculate the surface area within the constructuve solid geometry method.
+ */
+class ApproximateShapeArea
+{
+public:
+	ApproximateShapeArea(const Shape &_shape);
+	~ApproximateShapeArea();
+
+	double operator()() const;
+
+private:
+	Shape shape;
+};
+
+
+#endif /* APPROXIMATESHAPEAREA_HPP_ */
Index: src/Tesselation/ApproximateShapeVolume.cpp
===================================================================
--- src/Tesselation/ApproximateShapeVolume.cpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
+++ src/Tesselation/ApproximateShapeVolume.cpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
@@ -0,0 +1,76 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * ApproximateShapeVolume.cpp
+ *
+ *  Created on: Jan 30, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "ApproximateShapeVolume.hpp"
+
+#include <boost/bind.hpp>
+#include <vector>
+
+#include "Box.hpp"
+#include "Filling/Mesh/CubeMesh.hpp"
+#include "Filling/NodeTypes.hpp"
+#include "LinearAlgebra/RealSpaceMatrix.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "World.hpp"
+
+/** Constructor of class ApproximateShapeVolume.
+ *
+ * @param _shape shape to calculate the volume approximately
+ */
+ApproximateShapeVolume::ApproximateShapeVolume(const Shape &_shape) :
+		shape(_shape)
+{}
+
+/** Destructor of class ApproximateShapeVolume.
+ *
+ */
+ApproximateShapeVolume::~ApproximateShapeVolume()
+{}
+
+/** Calculate the approximate volume of the given \a shape.
+ *
+ * @return surface volume approximated
+ */
+double ApproximateShapeVolume::operator()() const
+{
+	// TODO
+	// generate mesh of points to "integrate"
+	const double min_distance = 10.;
+	Vector distance(min_distance,min_distance,min_distance);
+	const RealSpaceMatrix &M = World::getInstance().getDomain().getM();
+	Mesh *mesh = new CubeMesh(distance, Vector(0.5,0.5,0.5), M );
+	NodeSet nodes = mesh->getNodes();
+
+	// fill with grid points and count whether isInside
+	const size_t total = nodes.size();
+	size_t inside = 0;
+	for (NodeSet::const_iterator iter = nodes.begin();
+			iter != nodes.end(); ++iter) {
+		if (shape.isInside(*iter))
+			++inside;
+	}
+
+	// calculate volume of box
+	const double volume = M.determinant();
+
+	// return fraction that is inside
+	return volume*((double)inside/(double)total);
+}
Index: src/Tesselation/ApproximateShapeVolume.hpp
===================================================================
--- src/Tesselation/ApproximateShapeVolume.hpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
+++ src/Tesselation/ApproximateShapeVolume.hpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
@@ -0,0 +1,36 @@
+/*
+ * ApproximateShapeVolume.hpp
+ *
+ *  Created on: Jan 30, 2012
+ *      Author: heber
+ */
+
+#ifndef APPROXIMATESHAPEVOLUME_HPP_
+#define APPROXIMATESHAPEVOLUME_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Shapes/Shape.hpp"
+
+/** Functor for the approximate volume of a shape.
+ *
+ * This class is just an intermediate until we have implemented a better way
+ * to calculate the volume within the constructuve solid geometry method.
+ */
+class ApproximateShapeVolume
+{
+public:
+	ApproximateShapeVolume(const Shape &_shape);
+	~ApproximateShapeVolume();
+
+	double operator()() const;
+
+private:
+	Shape shape;
+};
+
+
+#endif /* APPROXIMATESHAPEVOLUME_HPP_ */
Index: src/Tesselation/BoundaryTriangleSet.cpp
===================================================================
--- src/Tesselation/BoundaryTriangleSet.cpp	(revision 22425a9c1deaa6c8fe8844c40fe08d87a46164b9)
+++ src/Tesselation/BoundaryTriangleSet.cpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
@@ -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;
@@ -370,4 +371,79 @@
 }
 ;
+
+/** Checks whether a given point is inside the plane of the triangle and inside the
+ * bounds defined by its BoundaryLineSet's.
+ *
+ * @param point point to check
+ * @return true - point is inside place and inside all BoundaryLine's
+ */
+bool BoundaryTriangleSet::IsInsideTriangle(const Vector &point) const
+{
+  Info FunctionInfo(__func__);
+
+  // check if it's inside the plane
+  try {
+    Plane trianglePlane(
+        endpoints[0]->node->getPosition(),
+        endpoints[1]->node->getPosition(),
+        endpoints[2]->node->getPosition());
+    if (!trianglePlane.isContained(point)) {
+      LOG(1, "INFO: Point " << point << " is not inside plane " << trianglePlane << " by "
+          << trianglePlane.distance(point) << ".");
+      return false;
+    }
+  } catch(LinearDependenceException) {
+    // triangle is degenerated, it's just a line (i.e. one endpoint is right in between two others
+    for (size_t i = 0; i < NDIM; ++i) {
+      try {
+        Line l = makeLineThrough(
+            lines[i]->endpoints[0]->node->getPosition(),
+            lines[i]->endpoints[1]->node->getPosition());
+        if (l.isContained(GetThirdEndpoint(lines[i])->node->getPosition())) {
+          // we have the largest of the three lines
+          LOG(1, "INFO: Linear-dependent case where point " << point << " is on line " << l << ".");
+          return (l.isContained(point));
+        }
+      } catch(ZeroVectorException) {
+        // two points actually coincide
+        try {
+          Line l = makeLineThrough(
+              lines[i]->endpoints[0]->node->getPosition(),
+              GetThirdEndpoint(lines[i])->node->getPosition());
+          LOG(1, "INFO: Degenerated case where point " << point << " is on line " << l << ".");
+          return (l.isContained(point));
+        } catch(ZeroVectorException) {
+          // all three points coincide
+          if (point.DistanceSquared(lines[i]->endpoints[0]->node->getPosition()) < MYEPSILON) {
+            LOG(1, "INFO: Full-Degenerated case where point " << point << " is on three endpoints "
+                << lines[i]->endpoints[0]->node->getPosition() << ".");
+            return true;
+          }
+          else return false;
+        }
+      }
+    }
+  }
+
+  // check whether it lies on the correct side as given by third endpoint for
+  // each BoundaryLine.
+  // NOTE: we assume here that endpoints are linear independent, as the case
+  // has been caught before already extensively
+  for (size_t i = 0; i < NDIM; ++i) {
+    Line l = makeLineThrough(
+        lines[i]->endpoints[0]->node->getPosition(),
+        lines[i]->endpoints[1]->node->getPosition());
+    Vector onLine( l.getClosestPoint(point) );
+    LOG(1, "INFO: Closest point on boundary line is " << onLine << ".");
+    Vector inTriangleDirection( GetThirdEndpoint(lines[i])->node->getPosition() - onLine );
+    Vector inPointDirection(point - onLine);
+    if ((inTriangleDirection.NormSquared() > MYEPSILON) && (inPointDirection.NormSquared() > MYEPSILON))
+      if (inTriangleDirection.ScalarProduct(inPointDirection) < -MYEPSILON)
+        return false;
+  }
+
+  return true;
+}
+
 
 /** Returns the endpoint which is not contained in the given \a *line.
Index: src/Tesselation/BoundaryTriangleSet.hpp
===================================================================
--- src/Tesselation/BoundaryTriangleSet.hpp	(revision 22425a9c1deaa6c8fe8844c40fe08d87a46164b9)
+++ src/Tesselation/BoundaryTriangleSet.hpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
@@ -42,4 +42,5 @@
     bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const;
     bool IsPresentTupel(const BoundaryTriangleSet * const T) const;
+    bool IsInsideTriangle(const Vector &point) const;
 
     Plane getPlane() const;
Index: src/Tesselation/boundary.cpp
===================================================================
--- src/Tesselation/boundary.cpp	(revision 22425a9c1deaa6c8fe8844c40fe08d87a46164b9)
+++ src/Tesselation/boundary.cpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
@@ -1029,5 +1029,5 @@
   for (int i=0;i<NDIM;i++) {
     phi[i] = (random()/(rng_max-rng_min))*(2.*M_PI);
-    std::cout << "Random angle is " << phi[i] << std::endl;
+    LOG(4, "DEBUG: Random angle is " << phi[i] << ".");
   }
 
Index: src/Tesselation/triangleintersectionlist.cpp
===================================================================
--- src/Tesselation/triangleintersectionlist.cpp	(revision 22425a9c1deaa6c8fe8844c40fe08d87a46164b9)
+++ src/Tesselation/triangleintersectionlist.cpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
@@ -197,10 +197,33 @@
   if (!DistanceList.empty()) {
     // get closest triangle(s)
-    std::pair< DistanceTriangleMap::iterator, DistanceTriangleMap::iterator >  DistanceRange =
+    std::pair< DistanceTriangleMap::const_iterator, DistanceTriangleMap::const_iterator >  DistanceRange =
         DistanceList.equal_range(DistanceList.begin()->first);
+    {
+      size_t count = 0;
+      for (DistanceTriangleMap::const_iterator iter = DistanceRange.first;
+          iter != DistanceRange.second; ++iter)
+        ++count;
+      LOG(1, "INFO: There are " << count << " possible triangles at the smallest distance.");
+    }
     // if there is more than one, check all of their normal vectors
-    // return the one with positive SKP if present
-
-    runner = IntersectionList.find(DistanceList.begin()->second);
+    // return the one with positive SKP if present because if the point
+    // would be truely inside, all of the closest triangles would have to show
+    // their inner side
+    LOG(1, "INFO: Looking for first SKP greater than zero ...");
+    for (DistanceTriangleMap::const_iterator iter = DistanceRange.first;
+        iter != DistanceRange.second; ++iter) {
+      // find the entry by the triangle key in IntersectionList to get the Intersection point
+      runner = IntersectionList.find(iter->second);
+      Vector TestVector = (Point) - (*(*runner).second);
+      // construct SKP
+      const double sign = (*iter).second->NormalVector.ScalarProduct(TestVector);
+      LOG(1, "INFO: Checking SKP of closest triangle " << *(iter->second) << " = " << sign << ".");
+      // if positive return
+      if (sign > 0)
+        break;
+    }
+    // if there's just one or all are negative, runner is not set yet
+    if (runner == IntersectionList.end())
+      runner = IntersectionList.find(DistanceList.begin()->second);
   }
   return runner;
Index: src/Tesselation/unittests/Makefile.am
===================================================================
--- src/Tesselation/unittests/Makefile.am	(revision 22425a9c1deaa6c8fe8844c40fe08d87a46164b9)
+++ src/Tesselation/unittests/Makefile.am	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
@@ -14,7 +14,6 @@
 TESSELATIONTESTS = \
   TesselationUnitTest \
-  Tesselation_BoundaryTriangleUnitTest
-  
-XFAIL_TESTS += Tesselation_InOutsideUnitTest
+  Tesselation_BoundaryTriangleUnitTest \
+  Tesselation_InOutsideUnitTest
 
 TESTS += $(TESSELATIONTESTS)
Index: src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp
===================================================================
--- src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp	(revision 22425a9c1deaa6c8fe8844c40fe08d87a46164b9)
+++ src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
@@ -30,4 +30,7 @@
 #include "Helpers/defs.hpp"
 #include "Atom/TesselPoint.hpp"
+#include "LinearAlgebra/Plane.hpp"
+#include "LinearAlgebra/RealSpaceMatrix.hpp"
+#include "LinearAlgebra/VectorSet.hpp"
 #include "Tesselation/BoundaryPointSet.hpp"
 #include "Tesselation/BoundaryLineSet.hpp"
@@ -49,24 +52,16 @@
 
 
-void TesselationBoundaryTriangleTest::setUp()
-{
-  setVerbosity(5);
+void TesselationBoundaryTriangleTest::createTriangle(const std::vector<Vector> &Vectors)
+{
+  CPPUNIT_ASSERT_EQUAL( (size_t)3, Vectors.size() );
 
   // create nodes
-  tesselpoints[0] = new TesselPoint;
-  tesselpoints[0]->setPosition(Vector(0., 0., 0.));
-  tesselpoints[0]->setName("1");
-  tesselpoints[0]->setNr(1);
-  points[0] = new BoundaryPointSet(tesselpoints[0]);
-  tesselpoints[1] = new TesselPoint;
-  tesselpoints[1]->setPosition(Vector(0., 1., 0.));
-  tesselpoints[1]->setName("2");
-  tesselpoints[1]->setNr(2);
-  points[1] = new BoundaryPointSet(tesselpoints[1]);
-  tesselpoints[2] = new TesselPoint;
-  tesselpoints[2]->setPosition(Vector(1., 0., 0.));
-  tesselpoints[2]->setName("3");
-  tesselpoints[2]->setNr(3);
-  points[2] = new BoundaryPointSet(tesselpoints[2] );
+  for (size_t count = 0; count < NDIM; ++count) {
+    tesselpoints[count] = new TesselPoint;
+    tesselpoints[count]->setPosition( Vectors[count] );
+    tesselpoints[count]->setName(toString(count));
+    tesselpoints[count]->setNr(count);
+    points[count] = new BoundaryPointSet(tesselpoints[count]);
+  }
 
   // create line
@@ -77,7 +72,21 @@
   // create triangle
   triangle = new BoundaryTriangleSet(lines, 0);
-  triangle->GetNormalVector(Vector(0.,0.,1.));
-};
-
+  Plane p(Vectors[0], Vectors[1], Vectors[2]);
+  triangle->GetNormalVector(p.getNormal());
+}
+
+void TesselationBoundaryTriangleTest::setUp()
+{
+  setVerbosity(5);
+
+  // create nodes
+  std::vector<Vector> Vectors;
+  Vectors.push_back( Vector(0., 0., 0.) );
+  Vectors.push_back( Vector(0., 1., 0.) );
+  Vectors.push_back( Vector(1., 0., 0.) );
+
+  // create triangle
+  createTriangle(Vectors);
+}
 
 void TesselationBoundaryTriangleTest::tearDown()
@@ -90,5 +99,213 @@
   logger::purgeInstance();
   errorLogger::purgeInstance();
-};
+}
+
+/** UnitTest for Tesselation::IsInsideTriangle()
+ */
+void TesselationBoundaryTriangleTest::IsInsideTriangleTest()
+{
+  // inside points
+  {
+    // check each endnode
+    for (size_t i=0; i< NDIM; ++i) {
+      const Vector testPoint(triangle->endpoints[i]->node->getPosition());
+      LOG(1, "INFO: Testing whether " << testPoint << " is an inner point.");
+      CPPUNIT_ASSERT( triangle->IsInsideTriangle( testPoint ) );
+    }
+  }
+
+  {
+    // check points along each BoundaryLine
+    for (size_t i=0; i< NDIM; ++i) {
+      Vector offset = triangle->endpoints[i%3]->node->getPosition();
+      Vector direction = triangle->endpoints[(i+1)%3]->node->getPosition() - offset;
+      for (double s = 0.1; s < 1.; s+= 0.1) {
+        Vector testPoint = offset + s*direction;
+        LOG(1, "INFO: Testing whether " << testPoint << " is an inner point.");
+        CPPUNIT_ASSERT( triangle->IsInsideTriangle( testPoint ) );
+      }
+    }
+  }
+
+  {
+    // check central point
+    Vector center;
+    triangle->GetCenter(center);
+    LOG(1, "INFO: Testing whether " << center << " is an inner point.");
+    CPPUNIT_ASSERT( triangle->IsInsideTriangle( center ) );
+  }
+
+  // outside points
+  {
+    // check points outside (i.e. those not in xy-plane through origin)
+    double n[3];
+    const double boundary = 4.;
+    const double step = 1.;
+    // go through the cube and check each point
+    for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
+      for (n[1] = -boundary; n[1] <= boundary; n[1]+=step)
+        for (n[2] = -boundary; n[2] <= boundary; n[2]+=step) {
+          const Vector testPoint(n[0], n[1], n[2]);
+          if (n[2] != 0) {
+            LOG(1, "INFO: Testing whether " << testPoint << " is not an inner point.");
+            CPPUNIT_ASSERT( !triangle->IsInsideTriangle( testPoint ) );
+          }
+        }
+  }
+
+  {
+    // check points within the plane but outside of triangle
+    double n[3];
+    const double boundary = 4.;
+    const double step = 1.;
+    n[2] = 0;
+    for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
+      for (n[1] = -boundary; n[1] <= boundary; n[1]+=step) {
+        const Vector testPoint(n[0], n[1], n[2]);
+        if ((n[0] >=0) && (n[1] >=0) && (n[0]<=1) && (n[1]<=1)) {
+          if (n[0]+n[1] <= 1) {
+            LOG(1, "INFO: Testing whether " << testPoint << " is an inner point.");
+            CPPUNIT_ASSERT( triangle->IsInsideTriangle( testPoint) );
+          } else {
+            LOG(1, "INFO: Testing whether " << testPoint << " is not an inner point.");
+            CPPUNIT_ASSERT( !triangle->IsInsideTriangle( testPoint) );
+          }
+        } else {
+          LOG(1, "INFO: Testing whether " << testPoint << " is not an inner point.");
+          CPPUNIT_ASSERT( !triangle->IsInsideTriangle( testPoint) );
+        }
+      }
+  }
+}
+
+/** UnitTest for Tesselation::IsInsideTriangle()
+ *
+ * We test for some specific points that occured in larger examples of the code.
+ *
+ */
+void TesselationBoundaryTriangleTest::IsInsideTriangle_specificTest()
+{
+  {
+    delete triangle;
+    // test is from --create-micelle 200 --radius 30. --position "0,0,0" of sles.data
+    // failure is: Intersection (23.1644,24.1867,65.1272) is not inside triangle [659|Na2451,O3652,Na3762].
+    const Vector testPoint(1.57318,1.57612,10.9874);
+    const Vector testIntersection(23.1644,24.1867,65.1272);
+    std::vector<Vector> vectors;
+    vectors.push_back( Vector(23.0563,30.4673,73.7555) );
+    vectors.push_back( Vector(25.473,25.1512,68.5467) );
+    vectors.push_back( Vector(23.1644,24.1867,65.1272) );
+    createTriangle(vectors);
+    CPPUNIT_ASSERT( triangle->IsInsideTriangle( testIntersection ) );
+  }
+  {
+    delete triangle;
+    // test is from --create-micelle 200 --radius 30. --position "0,0,0" of sles.data
+    // failure is: Intersection (20.6787,70.655,71.5657) is not inside triangle [622|Na1197,Na2166,O3366].
+    // fix is lower LINALG_MYEPSILON (not std::numeric_limits<doubble>*100 but *1e-4)
+    const Vector testPoint(1.57318,14.185,61.2155);
+    const Vector testIntersection(20.67867516517798,70.65496977054023,71.56572984946152);
+    std::vector<Vector> vectors;
+    vectors.push_back( Vector(22.9592,68.7791,77.5907) );
+    vectors.push_back( Vector(18.4729,72.0386,68.08839999999999) );
+    vectors.push_back( Vector(20.3834,71.0154,70.1443) );
+    createTriangle(vectors);
+    CPPUNIT_ASSERT( triangle->IsInsideTriangle( testIntersection ) );
+  }
+  {
+    delete triangle;
+    // test is from --create-micelle 200 --radius 30. --position "0,0,0" of sles.data
+    // 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!
+    // 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) );
+    vectors.push_back( Vector(13.7119,37.0827,47.4203) );
+    vectors.push_back( Vector(14.6872,36.204,39.8043) );
+    createTriangle(vectors);
+    CPPUNIT_ASSERT( triangle->IsInsideTriangle( testIntersection ) );
+  }
+}
+
+/** UnitTest for Tesselation::GetClosestPointInsideTriangle()
+ *
+ * We check whether this function always returns a intersection inside the
+ * triangle.
+ *
+ */
+void TesselationBoundaryTriangleTest::GetClosestPointInsideTriangleTest()
+{
+  Vector TestIntersection;
+
+  {
+    // march through a cube mesh on triangle in xy plane
+    double n[3];
+    const double boundary = 4.;
+    const double step = 1.;
+    // go through the cube and check each point
+    for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
+      for (n[1] = -boundary; n[1] <= boundary; n[1]+=step)
+        for (n[2] = -boundary; n[2] <= boundary; n[2]+=step) {
+          const Vector testPoint(n[0], n[1], n[2]);
+          triangle->GetClosestPointInsideTriangle(testPoint, TestIntersection);
+          CPPUNIT_ASSERT( triangle->IsInsideTriangle( TestIntersection ));
+        }
+  }
+
+  delete triangle;
+  // create better triangle;
+  VECTORSET(std::vector) Vectors;
+  Vectors.push_back( Vector(0., 0., 0.) );
+  Vectors.push_back( Vector(0., 1., 0.) );
+  Vectors.push_back( Vector(1., 0., 0.) );
+  RealSpaceMatrix M;
+  M.setRotation(M_PI/3., M_PI/4., 2.*M_PI/3.);
+  Vectors.transform(M);
+  createTriangle(Vectors);
+
+  {
+    // march through a cube mesh on rotated triangle
+    double n[3];
+    const double boundary = 4.;
+    const double step = 1.;
+    // go through the cube and check each point
+    for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
+      for (n[1] = -boundary; n[1] <= boundary; n[1]+=step)
+        for (n[2] = -boundary; n[2] <= boundary; n[2]+=step) {
+          const Vector testPoint(n[0], n[1], n[2]);
+          triangle->GetClosestPointInsideTriangle(testPoint, TestIntersection);
+          CPPUNIT_ASSERT( triangle->IsInsideTriangle( TestIntersection ));
+        }
+  }
+}
+
+/** UnitTest for Tesselation::GetClosestPointInsideTriangle()
+ *
+ * We test for some specific points that occured in larger examples of the code.
+ *
+ */
+void TesselationBoundaryTriangleTest::GetClosestPointInsideTriangle_specificTest()
+{
+  {
+    delete triangle;
+    // test is from --create-micelle 200 --radius 30. --position "0,0,0" of sles.data
+    // 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
+    // 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;
+    vectors.push_back( Vector(10.7513,43.4247,48.4127) );
+    vectors.push_back( Vector(13.7119,37.0827,47.4203) );
+    vectors.push_back( Vector(14.6872,36.204,39.8043) );
+    createTriangle(vectors);
+    triangle->GetClosestPointInsideTriangle(testPoint, testIntersection);
+    CPPUNIT_ASSERT ( testPoint != testIntersection );
+    CPPUNIT_ASSERT ( testPoint2 == testIntersection );
+  }
+}
 
 /** UnitTest for Tesselation::IsInnerPoint()
Index: src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp
===================================================================
--- src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp	(revision 22425a9c1deaa6c8fe8844c40fe08d87a46164b9)
+++ src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp	(revision 2935fddcbade4d132f34943ad80b643b77283a4b)
@@ -19,4 +19,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
+#include <vector>
+
+#include "LinearAlgebra/Vector.hpp"
 #include "LinkedCell/linkedcell.hpp"
 #include "Tesselation/tesselation.hpp"
@@ -29,4 +32,8 @@
 {
     CPPUNIT_TEST_SUITE( TesselationBoundaryTriangleTest) ;
+    CPPUNIT_TEST ( IsInsideTriangleTest );
+    CPPUNIT_TEST ( IsInsideTriangle_specificTest );
+    CPPUNIT_TEST ( GetClosestPointInsideTriangleTest );
+    CPPUNIT_TEST ( GetClosestPointInsideTriangle_specificTest );
     CPPUNIT_TEST ( GetClosestPointOnPlaneTest );
     CPPUNIT_TEST ( GetClosestPointOffPlaneTest );
@@ -36,8 +43,14 @@
       void setUp();
       void tearDown();
+      void IsInsideTriangleTest();
+      void IsInsideTriangle_specificTest();
+      void GetClosestPointInsideTriangleTest();
+      void GetClosestPointInsideTriangle_specificTest();
       void GetClosestPointOnPlaneTest();
       void GetClosestPointOffPlaneTest();
 
 private:
+      void createTriangle(const std::vector<Vector> &Vectors);
+
       static const double SPHERERADIUS;
 
