Index: src/unittests/AnalysisCorrelationToPointUnitTest.cpp
===================================================================
--- src/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision 1ca488f7e320046e400e980657d7c0d91e0356ae)
+++ src/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -11,4 +11,6 @@
 #include <cppunit/extensions/TestFactoryRegistry.h>
 #include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
 
 #include "analysis_correlation.hpp"
Index: src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp
===================================================================
--- src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp	(revision 1ca488f7e320046e400e980657d7c0d91e0356ae)
+++ src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -11,4 +11,6 @@
 #include <cppunit/extensions/TestFactoryRegistry.h>
 #include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
 
 #include "analysis_correlation.hpp"
Index: src/unittests/AnalysisPairCorrelationUnitTest.cpp
===================================================================
--- src/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision 1ca488f7e320046e400e980657d7c0d91e0356ae)
+++ src/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -11,4 +11,6 @@
 #include <cppunit/extensions/TestFactoryRegistry.h>
 #include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
 
 #include "analysis_correlation.hpp"
Index: src/unittests/Makefile.am
===================================================================
--- src/unittests/Makefile.am	(revision 1ca488f7e320046e400e980657d7c0d91e0356ae)
+++ src/unittests/Makefile.am	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -6,47 +6,89 @@
 MENUTESTS = ActionSequenceTest
 
-TESTS = ActOnAllUnitTest AnalysisBondsUnitTests AnalysisCorrelationToPointUnitTest AnalysisCorrelationToSurfaceUnitTest AnalysisPairCorrelationUnitTest BondGraphUnitTest InfoUnitTest ListOfBondsUnitTest LogUnitTest MemoryUsageObserverUnitTest MemoryAllocatorUnitTest StackClassUnitTest VectorUnitTest ${MENUTESTS}
-
-check_PROGRAMS = $(TESTS)
-noinst_PROGRAMS = $(TESTS)
+TESTS = \
+  ActOnAllUnitTest \
+  AnalysisBondsUnitTests \
+  AnalysisCorrelationToPointUnitTest \
+  AnalysisCorrelationToSurfaceUnitTest \
+  AnalysisPairCorrelationUnitTest \
+  BondGraphUnitTest \
+  GSLMatrixSymmetricUnitTest \
+  GSLMatrixUnitTest \
+  GSLVectorUnitTest \
+  InfoUnitTest \
+  LinearSystemOfEquationsUnitTest \
+  ListOfBondsUnitTest \
+  LogUnitTest \
+  MemoryUsageObserverUnitTest \
+  MemoryAllocatorUnitTest \
+  StackClassUnitTest \
+  TesselationUnitTest \
+  Tesselation_BoundaryTriangleUnitTest \
+  Tesselation_InOutsideUnitTest \
+  VectorUnitTest
+    
+  
+check_PROGRAMS = $(TESTS) ${MENUTESTS}
+noinst_PROGRAMS = $(TESTS) ${MENUTESTS}
 
 ActOnAllUnitTest_SOURCES = ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
-ActOnAllUnitTest_LDADD = ../libmolecuilder.a
+ActOnAllUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
 
 AnalysisBondsUnitTests_SOURCES = analysisbondsunittest.cpp analysisbondsunittest.hpp
-AnalysisBondsUnitTests_LDADD = ../libmolecuilder.a
+AnalysisBondsUnitTests_LDADD = ../libmolecuilder.a ../libgslwrapper.a
 
 AnalysisCorrelationToPointUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToPointUnitTest.cpp AnalysisCorrelationToPointUnitTest.hpp
-AnalysisCorrelationToPointUnitTest_LDADD = ../libmolecuilder.a
+AnalysisCorrelationToPointUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
 
 AnalysisCorrelationToSurfaceUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToSurfaceUnitTest.cpp AnalysisCorrelationToSurfaceUnitTest.hpp
-AnalysisCorrelationToSurfaceUnitTest_LDADD = ../libmolecuilder.a
+AnalysisCorrelationToSurfaceUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
 
 AnalysisPairCorrelationUnitTest_SOURCES = analysis_correlation.hpp AnalysisPairCorrelationUnitTest.cpp AnalysisPairCorrelationUnitTest.hpp
-AnalysisPairCorrelationUnitTest_LDADD = ../libmolecuilder.a
+AnalysisPairCorrelationUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
 
 BondGraphUnitTest_SOURCES = bondgraphunittest.cpp bondgraphunittest.hpp
-BondGraphUnitTest_LDADD = ../libmolecuilder.a
+BondGraphUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
+
+GSLMatrixSymmetricUnitTest_SOURCES = gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp
+GSLMatrixSymmetricUnitTest_LDADD = ../libgslwrapper.a
+
+GSLMatrixUnitTest_SOURCES = gslmatrixunittest.cpp gslmatrixunittest.hpp
+GSLMatrixUnitTest_LDADD = ../libgslwrapper.a
+
+GSLVectorUnitTest_SOURCES = gslvectorunittest.cpp gslvectorunittest.hpp
+GSLVectorUnitTest_LDADD = ../libgslwrapper.a
 
 InfoUnitTest_SOURCES = infounittest.cpp infounittest.hpp
-InfoUnitTest_LDADD = ../libmolecuilder.a
+InfoUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
+
+LinearSystemOfEquationsUnitTest_SOURCES = linearsystemofequationsunittest.cpp linearsystemofequationsunittest.hpp
+LinearSystemOfEquationsUnitTest_LDADD = ../libgslwrapper.a ../libmolecuilder.a
 
 ListOfBondsUnitTest_SOURCES = listofbondsunittest.cpp listofbondsunittest.hpp
-ListOfBondsUnitTest_LDADD = ../libmolecuilder.a
+ListOfBondsUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
 
 LogUnitTest_SOURCES = logunittest.cpp logunittest.hpp 
-LogUnitTest_LDADD = ../libmolecuilder.a
+LogUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
 
 MemoryAllocatorUnitTest_SOURCES = memoryallocatorunittest.cpp memoryallocatorunittest.hpp 
-MemoryAllocatorUnitTest_LDADD = ../libmolecuilder.a
+MemoryAllocatorUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
 
 MemoryUsageObserverUnitTest_SOURCES = memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp 
-MemoryUsageObserverUnitTest_LDADD = ../libmolecuilder.a
+MemoryUsageObserverUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
 
 StackClassUnitTest_SOURCES = stackclassunittest.cpp stackclassunittest.hpp
-StackClassUnitTest_LDADD = ../libmolecuilder.a
+StackClassUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
+
+TesselationUnitTest_SOURCES = tesselationunittest.cpp tesselationunittest.hpp
+TesselationUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
+
+Tesselation_BoundaryTriangleUnitTest_SOURCES = tesselation_boundarytriangleunittest.cpp tesselation_boundarytriangleunittest.hpp
+Tesselation_BoundaryTriangleUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
+
+Tesselation_InOutsideUnitTest_SOURCES = tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp
+Tesselation_InOutsideUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
 
 VectorUnitTest_SOURCES = vectorunittest.cpp vectorunittest.hpp 
-VectorUnitTest_LDADD = ../libmolecuilder.a
+VectorUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
 
 ActionSequenceTest_SOURCES = ActionSequenceTest.cpp ActionSequenceTest.hpp
Index: src/unittests/analysisbondsunittest.cpp
===================================================================
--- src/unittests/analysisbondsunittest.cpp	(revision 1ca488f7e320046e400e980657d7c0d91e0356ae)
+++ src/unittests/analysisbondsunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -14,4 +14,5 @@
 #include <iostream>
 #include <stdio.h>
+#include <cstring>
 
 #include "analysis_bonds.hpp"
Index: src/unittests/bondgraphunittest.cpp
===================================================================
--- src/unittests/bondgraphunittest.cpp	(revision 1ca488f7e320046e400e980657d7c0d91e0356ae)
+++ src/unittests/bondgraphunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -14,4 +14,5 @@
 #include <iostream>
 #include <stdio.h>
+#include <cstring>
 
 #include "atom.hpp"
Index: src/unittests/gslmatrixsymmetricunittest.cpp
===================================================================
--- src/unittests/gslmatrixsymmetricunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
+++ src/unittests/gslmatrixsymmetricunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -0,0 +1,288 @@
+/*
+ * gslmatrixunittest.cpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "gslmatrixsymmetricunittest.hpp"
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( GSLMatrixSymmetricTest );
+
+
+void GSLMatrixSymmetricTest::setUp()
+{
+  m = new GSLMatrix(3,3);
+};
+
+void GSLMatrixSymmetricTest::tearDown()
+{
+  delete(m);
+};
+
+/** Unit Test for accessing matrix elements.
+ *
+ */
+void GSLMatrixSymmetricTest::AccessTest()
+{
+  // check whether all elements are initially zero
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( 0., m->Get(i,j) );
+
+  // set
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, i*3+j );
+
+  // and check
+  double *ptr = NULL;
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++) {
+      CPPUNIT_ASSERT_EQUAL( (double)(i*3+j), m->Get(i,j) );
+      ptr = m->Pointer(i,j);
+      CPPUNIT_ASSERT_EQUAL( (double)(i*3+j), *ptr );
+    }
+
+  // assignment
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, i*3+j );
+  GSLMatrix *dest = new GSLMatrix(3,3);
+  *dest = *m;
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( dest->Get(i,j), m->Get(i,j) );
+  delete(dest);
+
+  // out of bounds
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(4,2) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(2,17) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(1024,140040) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(-1,0) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(0,-1) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(-1,-1) );
+};
+
+/** Unit Test for initializating matrices.
+ *
+ */
+void GSLMatrixSymmetricTest::InitializationTest()
+{
+  // set zero
+  m->SetZero();
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( 0., m->Get(i,j) );
+
+  // set all
+  m->SetAll(1.5);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( 1.5, m->Get(i,j) );
+
+  // set basis
+  m->SetIdentity();
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , m->Get(i,j) );
+
+  // set from array
+  double array[] = { 1., 0., 0.,
+                     0., 1., 0.,
+                     0., 0., 1. };
+  m->SetFromDoubleArray(array);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , m->Get(i,j) );
+
+};
+
+/** Unit Test for copying matrices.
+ *
+ */
+void GSLMatrixSymmetricTest::CopyTest()
+{
+  // set basis
+  GSLMatrix *dest = NULL;
+  for (int i=0;i<3;i++) {
+    m->SetAll(i);
+    dest = new GSLMatrix(m);
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( m->Get(i,j) , dest->Get(i,j) );
+
+    delete(dest);
+  }
+};
+
+/** Unit Test for exchanging rows and columns.
+ *
+ */
+void GSLMatrixSymmetricTest::ExchangeTest()
+{
+  // set to 1,1,1,2, ...
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, i+1 );
+
+  // swap such that nothing happens
+  m->SwapColumns(1,2);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)i+1., m->Get(i,j) );
+
+  // swap two rows
+  m->SwapRows(1,2);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      switch (j) {
+        case 0:
+          CPPUNIT_ASSERT_EQUAL( 1., m->Get(j,i) );
+          break;
+        case 1:
+          CPPUNIT_ASSERT_EQUAL( 3., m->Get(j,i) );
+          break;
+        case 2:
+          CPPUNIT_ASSERT_EQUAL( 2., m->Get(j,i) );
+          break;
+        default:
+          CPPUNIT_ASSERT_EQUAL( -1., m->Get(i,j) );
+      }
+  // check that op is reversable
+  m->SwapRows(1,2);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)i+1., m->Get(i,j) );
+
+  // set to 1,2,3,1, ...
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, j+1. );
+
+  // swap such that nothing happens
+  m->SwapRows(0,2);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)j+1., m->Get(i,j) );
+
+  // swap two columns
+  m->SwapColumns(0,2);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      switch (j) {
+        case 0:
+          CPPUNIT_ASSERT_EQUAL( 3., m->Get(i,j) );
+          break;
+        case 1:
+          CPPUNIT_ASSERT_EQUAL( 2., m->Get(i,j) );
+          break;
+        case 2:
+          CPPUNIT_ASSERT_EQUAL( 1., m->Get(i,j) );
+          break;
+        default:
+          CPPUNIT_ASSERT_EQUAL( -1., m->Get(i,j) );
+      }
+  // check that op is reversable
+  m->SwapColumns(0,2);
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)j+1., m->Get(i,j) );
+
+
+  // set to 1,2,3,4, ...
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, 3*i+j+1 );
+  // transpose
+  m->Transpose();
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)(3*i+j+1), m->Get(j,i) );
+  // second transpose
+  m->Transpose();
+  for (int i=0;i<3;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)(3*i+j+1), m->Get(i,j) );
+};
+
+/** Unit Test for matrix properties.
+ *
+ */
+void GSLMatrixSymmetricTest::PropertiesTest()
+{
+  // is zero
+  m->SetZero();
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNull() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsPositive() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNegative() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNonNegative() );
+
+  // is positive
+  m->SetAll(0.5);
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNull() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsPositive() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNegative() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNonNegative() );
+
+  // is negative
+  m->SetAll(-0.1);
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNull() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsPositive() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNegative() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNonNegative() );
+
+  // is positive definite
+  double array[] = { 1., 0., 0.,
+                     0., 1., 1.,
+                     0., 0., 1. };
+  m->SetFromDoubleArray(array);
+  CPPUNIT_ASSERT_EQUAL( true, m->IsPositiveDefinite() );
+
+  //determinant
+  m->SetIdentity();
+  CPPUNIT_ASSERT_EQUAL( 1., m->Determinant() );
+
+  m->SetZero();
+  CPPUNIT_ASSERT_EQUAL( 0., m->Determinant() );
+
+  m->Set( 0, 0, 1.);
+  m->Set( 1, 1, 1.);
+  m->Set( 2, 1, 1.);
+  CPPUNIT_ASSERT_EQUAL( 0., m->Determinant() );
+  
+  double array2[] = { 2., 0., 1.,
+                     -3., 1., 1.,
+                     1., 5.5, 1. };
+  m->SetFromDoubleArray(array2);
+  CPPUNIT_ASSERT_EQUAL( -26.5, m->Determinant() );
+};
+
+/********************************************** Main routine **************************************/
+
+int main(int argc, char **argv)
+{
+  // Get the top level suite from the registry
+  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+
+  // Adds the test to the list of test to run
+  CppUnit::TextUi::TestRunner runner;
+  runner.addTest( suite );
+
+  // Change the default outputter to a compiler error format outputter
+  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
+                                                       std::cerr ) );
+  // Run the tests.
+  bool wasSucessful = runner.run();
+
+  // Return error code 1 if the one of test failed.
+  return wasSucessful ? 0 : 1;
+};
Index: src/unittests/gslmatrixsymmetricunittest.hpp
===================================================================
--- src/unittests/gslmatrixsymmetricunittest.hpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
+++ src/unittests/gslmatrixsymmetricunittest.hpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -0,0 +1,42 @@
+/*
+ * gslmatrixunittest.hpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+#ifndef GSLMATRIXUNITTEST_HPP_
+#define GSLMATRIXUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "gslmatrix.hpp"
+
+/********************************************** Test classes **************************************/
+
+class GSLMatrixSymmetricTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( GSLMatrixSymmetricTest) ;
+    CPPUNIT_TEST (AccessTest );
+    CPPUNIT_TEST (InitializationTest );
+    CPPUNIT_TEST (CopyTest );
+    CPPUNIT_TEST (ExchangeTest );
+    CPPUNIT_TEST (PropertiesTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void AccessTest();
+    void InitializationTest();
+    void CopyTest();
+    void ExchangeTest();
+    void PropertiesTest();
+
+private:
+    GSLMatrix *m;
+};
+
+
+#endif /* GSLMATRIXUNITTEST_HPP_ */
Index: src/unittests/gslmatrixunittest.cpp
===================================================================
--- src/unittests/gslmatrixunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
+++ src/unittests/gslmatrixunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -0,0 +1,270 @@
+/*
+ * gslmatrixunittest.cpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "gslmatrixunittest.hpp"
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( GSLMatrixTest );
+
+
+void GSLMatrixTest::setUp()
+{
+  m = new GSLMatrix(4,3);
+};
+
+void GSLMatrixTest::tearDown()
+{
+  delete(m);
+};
+
+/** Unit Test for accessing matrix elements.
+ *
+ */
+void GSLMatrixTest::AccessTest()
+{
+  // check whether all elements are initially zero
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( 0., m->Get(i,j) );
+
+  // set
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, i*3+j );
+
+  // and check
+  double *ptr = NULL;
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++) {
+      CPPUNIT_ASSERT_EQUAL( (double)(i*3+j), m->Get(i,j) );
+      ptr = m->Pointer(i,j);
+      CPPUNIT_ASSERT_EQUAL( (double)(i*3+j), *ptr );
+    }
+
+  // assignment
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, i*3+j );
+  GSLMatrix *dest = new GSLMatrix(4,3);
+  *dest = *m;
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( dest->Get(i,j), m->Get(i,j) );
+  delete(dest);
+
+  // out of bounds
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(5,2) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(2,17) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(1024,140040) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(-1,0) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(0,-1) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(-1,-1) );
+};
+
+/** Unit Test for initializating matrices.
+ *
+ */
+void GSLMatrixTest::InitializationTest()
+{
+  // set zero
+  m->SetZero();
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( 0., m->Get(i,j) );
+
+  // set all
+  m->SetAll(1.5);
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( 1.5, m->Get(i,j) );
+
+  // set basis
+  m->SetIdentity();
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , m->Get(i,j) );
+
+  // set from array
+  double array[] = { 1., 0., 0.,
+                     0., 1., 0.,
+                     0., 0., 1.,
+                     0., 0., 0. };
+  m->SetFromDoubleArray(array);
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , m->Get(i,j) );
+
+};
+
+/** Unit Test for copying matrices.
+ *
+ */
+void GSLMatrixTest::CopyTest()
+{
+  // set basis
+  GSLMatrix *dest = NULL;
+  for (int i=0;i<4;i++) {
+    m->SetAll(i);
+    dest = new GSLMatrix(m);
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( m->Get(i,j) , dest->Get(i,j) );
+
+    delete(dest);
+  }
+};
+
+/** Unit Test for exchanging rows and columns.
+ *
+ */
+void GSLMatrixTest::ExchangeTest()
+{
+  // set to 1,1,1,2, ...
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, i+1 );
+
+  // swap such that nothing happens
+  CPPUNIT_ASSERT_EQUAL( true, m->SwapColumns(1,2) );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)i+1., m->Get(i,j) );
+
+  // swap two rows
+  CPPUNIT_ASSERT_EQUAL( true, m->SwapRows(1,2) );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      switch (i) {
+        case 0:
+          CPPUNIT_ASSERT_EQUAL( 1., m->Get(i,j) );
+          break;
+        case 1:
+          CPPUNIT_ASSERT_EQUAL( 3., m->Get(i,j) );
+          break;
+        case 2:
+          CPPUNIT_ASSERT_EQUAL( 2., m->Get(i,j) );
+          break;
+        case 3:
+          CPPUNIT_ASSERT_EQUAL( 4., m->Get(i,j) );
+          break;
+        default:
+          CPPUNIT_ASSERT_EQUAL( -1., m->Get(i,j) );
+      }
+  // check that op is reversable
+  CPPUNIT_ASSERT_EQUAL( true, m->SwapRows(1,2) );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)i+1., m->Get(i,j) );
+
+  // set to 1,2,3,1, ...
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, j+1. );
+
+  // swap such that nothing happens
+  CPPUNIT_ASSERT_EQUAL( true, m->SwapRows(0,2) );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)j+1., m->Get(i,j) );
+
+  // swap two columns
+  CPPUNIT_ASSERT_EQUAL( true, m->SwapColumns(0,2) );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      switch (j) {
+        case 0:
+          CPPUNIT_ASSERT_EQUAL( 3., m->Get(i,j) );
+          break;
+        case 1:
+          CPPUNIT_ASSERT_EQUAL( 2., m->Get(i,j) );
+          break;
+        case 2:
+          CPPUNIT_ASSERT_EQUAL( 1., m->Get(i,j) );
+          break;
+        default:
+          CPPUNIT_ASSERT_EQUAL( -1., m->Get(i,j) );
+      }
+  // check that op is reversable
+  CPPUNIT_ASSERT_EQUAL( true, m->SwapColumns(0,2) );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)j+1., m->Get(i,j) );
+
+
+  // set to 1,2,3,4, ...
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      m->Set(i,j, 3*i+j+1 );
+  // transpose
+  CPPUNIT_ASSERT_EQUAL( true, m->Transpose() );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)(3*i+j+1), m->Get(j,i) );
+  // second transpose
+  CPPUNIT_ASSERT_EQUAL( true, m->Transpose() );
+  for (int i=0;i<4;i++)
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (double)(3*i+j+1), m->Get(i,j) );
+};
+
+/** Unit Test for matrix properties.
+ *
+ */
+void GSLMatrixTest::PropertiesTest()
+{
+  // is zero
+  m->SetZero();
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNull() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsPositive() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNegative() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNonNegative() );
+
+  // is positive
+  m->SetAll(0.5);
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNull() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsPositive() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNegative() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNonNegative() );
+
+  // is negative
+  m->SetAll(-0.1);
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNull() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsPositive() );
+  CPPUNIT_ASSERT_EQUAL( true, m->IsNegative() );
+  CPPUNIT_ASSERT_EQUAL( false, m->IsNonNegative() );
+
+  // is positive definite
+  CPPUNIT_ASSERT_EQUAL( false, m->IsPositiveDefinite() );
+};
+
+/********************************************** Main routine **************************************/
+
+int main(int argc, char **argv)
+{
+  // Get the top level suite from the registry
+  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+
+  // Adds the test to the list of test to run
+  CppUnit::TextUi::TestRunner runner;
+  runner.addTest( suite );
+
+  // Change the default outputter to a compiler error format outputter
+  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
+                                                       std::cerr ) );
+  // Run the tests.
+  bool wasSucessful = runner.run();
+
+  // Return error code 1 if the one of test failed.
+  return wasSucessful ? 0 : 1;
+};
Index: src/unittests/gslmatrixunittest.hpp
===================================================================
--- src/unittests/gslmatrixunittest.hpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
+++ src/unittests/gslmatrixunittest.hpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -0,0 +1,42 @@
+/*
+ * gslmatrixunittest.hpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+#ifndef GSLMATRIXUNITTEST_HPP_
+#define GSLMATRIXUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "gslmatrix.hpp"
+
+/********************************************** Test classes **************************************/
+
+class GSLMatrixTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( GSLMatrixTest) ;
+    CPPUNIT_TEST (AccessTest );
+    CPPUNIT_TEST (InitializationTest );
+    CPPUNIT_TEST (CopyTest );
+    CPPUNIT_TEST (ExchangeTest );
+    CPPUNIT_TEST (PropertiesTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void AccessTest();
+    void InitializationTest();
+    void CopyTest();
+    void ExchangeTest();
+    void PropertiesTest();
+
+private:
+    GSLMatrix *m;
+};
+
+
+#endif /* GSLMATRIXUNITTEST_HPP_ */
Index: src/unittests/gslvectorunittest.cpp
===================================================================
--- src/unittests/gslvectorunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
+++ src/unittests/gslvectorunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -0,0 +1,136 @@
+/*
+ * gslvectorunittest.cpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "gslvectorunittest.hpp"
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( GSLVectorTest );
+
+
+void GSLVectorTest::setUp()
+{
+  v = new GSLVector(3);
+};
+
+void GSLVectorTest::tearDown()
+{
+  delete(v);
+};
+
+/** Unit test for accessing elements in the vector.
+ *
+ */
+void GSLVectorTest::AccessTest()
+{
+  // set
+  for (int i=0;i<3;i++)
+    v->Set(i,i);
+
+  // and check
+  double *ptr = NULL;
+  for (int i=0;i<3;i++) {
+    CPPUNIT_ASSERT_EQUAL( (double)i, v->Get(i) );
+    ptr = v->Pointer(i);
+    CPPUNIT_ASSERT_EQUAL( (double)i, *ptr );
+  }
+
+  // out of bounds
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(3) );
+  //CPPUNIT_ASSERT_EQUAL(0., v->Get(-1) );
+};
+
+
+/** Unit test for initializing the vector.
+ *
+ */
+void GSLVectorTest::InitializaionTest()
+{
+  // set zero
+  v->SetZero();
+  for (int i=0;i<3;i++)
+    CPPUNIT_ASSERT_EQUAL( 0., v->Get(i) );
+
+  // set basis
+  for (int i=0;i<3;i++) {
+    v->SetBasis(i);
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , v->Get(j) );
+  }
+
+  // set all
+  v->SetAll(1.5);
+  for (int i=0;i<3;i++)
+    CPPUNIT_ASSERT_EQUAL( 1.5, v->Get(i) );
+};
+
+/** Unit test for copying vectors.
+ *
+ */
+void GSLVectorTest::CopyTest()
+{
+  // set basis
+  GSLVector *dest = NULL;
+  for (int i=0;i<3;i++) {
+    v->SetBasis(i);
+    dest = new GSLVector(v);
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( v->Get(j) , dest->Get(j) );
+
+    delete(dest);
+  }
+};
+
+/** Unit test for exchanging elements of a vector.
+ *
+ */
+void GSLVectorTest::ExchangeTest()
+{
+  // set basis
+  for (int i=0;i<3;i++) {
+    v->SetBasis(i);
+    v->SwapElements((i)%3,(i+1)%3);
+    for (int j=0;j<3;j++)
+      CPPUNIT_ASSERT_EQUAL( (i+1)%3 == j ? 1. : 0. , v->Get(j) );
+  }
+
+  // set to 1,2,3 and reverse
+  for (int i=0;i<3;i++)
+    v->Set(i,i+1);
+  v->Reverse();
+  for (int j=0;j<3;j++)
+    CPPUNIT_ASSERT_EQUAL( (double)(3-j), v->Get(j) );
+};
+
+
+/********************************************** Main routine **************************************/
+
+int main(int argc, char **argv)
+{
+  // Get the top level suite from the registry
+  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+
+  // Adds the test to the list of test to run
+  CppUnit::TextUi::TestRunner runner;
+  runner.addTest( suite );
+
+  // Change the default outputter to a compiler error format outputter
+  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
+                                                       std::cerr ) );
+  // Run the tests.
+  bool wasSucessful = runner.run();
+
+  // Return error code 1 if the one of test failed.
+  return wasSucessful ? 0 : 1;
+};
Index: src/unittests/gslvectorunittest.hpp
===================================================================
--- src/unittests/gslvectorunittest.hpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
+++ src/unittests/gslvectorunittest.hpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -0,0 +1,41 @@
+/*
+ * gslvectorunittest.hpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+#ifndef GSLVECTORUNITTEST_HPP_
+#define GSLVECTORUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "gslvector.hpp"
+
+/********************************************** Test classes **************************************/
+
+class GSLVectorTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( GSLVectorTest) ;
+    CPPUNIT_TEST (AccessTest );
+    CPPUNIT_TEST (InitializaionTest );
+    CPPUNIT_TEST (CopyTest );
+    CPPUNIT_TEST (ExchangeTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void AccessTest();
+    void InitializaionTest();
+    void CopyTest();
+    void ExchangeTest();
+
+private:
+
+    GSLVector *v;
+};
+
+
+#endif /* GSLVECTORUNITTEST_HPP_ */
Index: src/unittests/linearsystemofequationsunittest.cpp
===================================================================
--- src/unittests/linearsystemofequationsunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
+++ src/unittests/linearsystemofequationsunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -0,0 +1,125 @@
+/*
+ * linearsystemofequationsunittest.cpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <iomanip>
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "linearsystemofequationsunittest.hpp"
+#include "vector.hpp"
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( LinearSystemOfEquationsTest );
+
+
+void LinearSystemOfEquationsTest::setUp()
+{
+  s = new LinearSystemOfEquations(4,4);
+};
+
+void LinearSystemOfEquationsTest::tearDown()
+{
+  delete(s);
+};
+
+/** Unit test for initialization.
+ *
+ */
+void LinearSystemOfEquationsTest::InitializationTest()
+{
+  // Setting A
+  double array[] = { 1., 0., 0., 0.,
+                     0., 2., 0., 0.,
+                     0., 0., 3., 0.,
+                     0., 0., 0., 4. };
+  s->SetA(array);
+
+  // Setting b
+};
+
+/** Unit test for symmetry property.
+ *
+ */
+void LinearSystemOfEquationsTest::SymmetricTest()
+{
+  CPPUNIT_ASSERT_EQUAL( true, s->SetSymmetric(true) );
+  //LinearSystemOfEquations *t = new LinearSystemOfEquations(4,3);
+  //CPPUNIT_ASSERT_EQUAL( true, t->SetSymmetric(true) );
+  //delete(t);
+};
+
+/** Unit test for simple Solve.
+ *
+ */
+void LinearSystemOfEquationsTest::SolveSimpleTest()
+{
+  // set up A and b
+  double m_array[] = { 1., 0., 0., 0.,
+                       0., 2., 0., 0.,
+                       0., 0., 3., 0.,
+                       0., 0., 0., 4. };
+  double v_array[] = { 1., 2., 3., 4. };
+  s->SetA(m_array);
+  s->Setb(v_array);
+
+  // solve
+  double *array = new double[4];
+  s->GetSolutionAsArray(array);
+  for (int i=0;i<4;i++)
+    CPPUNIT_ASSERT_EQUAL( 1., array[i]);
+  delete[](array);
+};
+
+/** Unit test for advanced Solve.
+ *
+ */
+void LinearSystemOfEquationsTest::SolveAdvancedTest()
+{
+  // set up A and b
+  double m_array[] = { 0.18, 0.60, 0.57, 0.96,
+                       0.41, 0.24, 0.99, 0.58,
+                       0.14, 0.30, 0.97, 0.66,
+                       0.51, 0.13, 0.19, 0.85 };
+  double v_array[] = { 1.0, 2.0, 3.0, 4.0 };
+  double x_array[] = { -4.05205022957398, -12.60561139590692, 1.660911626708844, 8.693766928795233 };
+  s->SetA(m_array);
+  s->Setb(v_array);
+
+  // solve
+  double *array = new double[4];
+  s->GetSolutionAsArray(array);
+  for (int i=0;i<4;i++) {
+    CPPUNIT_ASSERT( fabs(x_array[i] - array[i]) < MYEPSILON );
+  }
+  delete[](array);
+};
+
+/********************************************** Main routine **************************************/
+
+int main(int argc, char **argv)
+{
+  // Get the top level suite from the registry
+  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+
+  // Adds the test to the list of test to run
+  CppUnit::TextUi::TestRunner runner;
+  runner.addTest( suite );
+
+  // Change the default outputter to a compiler error format outputter
+  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
+                                                       std::cerr ) );
+  // Run the tests.
+  bool wasSucessful = runner.run();
+
+  // Return error code 1 if the one of test failed.
+  return wasSucessful ? 0 : 1;
+};
Index: src/unittests/linearsystemofequationsunittest.hpp
===================================================================
--- src/unittests/linearsystemofequationsunittest.hpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
+++ src/unittests/linearsystemofequationsunittest.hpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -0,0 +1,40 @@
+/*
+ * linearsystemofequationsunittest.hpp
+ *
+ *  Created on: Jan 8, 2010
+ *      Author: heber
+ */
+
+#ifndef LINEARSYSTEMOFEQUATIONSUNITTEST_HPP_
+#define LINEARSYSTEMOFEQUATIONSUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "linearsystemofequations.hpp"
+
+/********************************************** Test classes **************************************/
+
+class LinearSystemOfEquationsTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( LinearSystemOfEquationsTest) ;
+    CPPUNIT_TEST ( InitializationTest );
+    CPPUNIT_TEST ( SymmetricTest );
+    CPPUNIT_TEST ( SolveSimpleTest );
+    CPPUNIT_TEST ( SolveAdvancedTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+    void setUp();
+    void tearDown();
+
+    void InitializationTest();
+    void SymmetricTest();
+    void SolveSimpleTest();
+    void SolveAdvancedTest();
+
+private:
+    LinearSystemOfEquations *s;
+};
+
+
+#endif /* LINEARSYSTEMOFEQUATIONSUNITTEST_HPP_ */
Index: src/unittests/listofbondsunittest.cpp
===================================================================
--- src/unittests/listofbondsunittest.cpp	(revision 1ca488f7e320046e400e980657d7c0d91e0356ae)
+++ src/unittests/listofbondsunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -11,4 +11,6 @@
 #include <cppunit/extensions/TestFactoryRegistry.h>
 #include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
 
 #include "listofbondsunittest.hpp"
Index: src/unittests/tesselation_boundarytriangleunittest.cpp
===================================================================
--- src/unittests/tesselation_boundarytriangleunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
+++ src/unittests/tesselation_boundarytriangleunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -0,0 +1,214 @@
+/*
+ * tesselation_boundarytriangleunittest.cpp
+ *
+ *  Created on: Jan 13, 2010
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
+
+#include "defs.hpp"
+#include "tesselation.hpp"
+#include "tesselation_boundarytriangleunittest.hpp"
+
+#define SPHERERADIUS 2.
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( TesselationBoundaryTriangleTest );
+
+
+void TesselationBoundaryTriangleTest::setUp()
+{
+  setVerbosity(5);
+
+  // create nodes
+  TesselPoint *Walker = NULL;
+  Walker = new TesselPoint;
+  Walker->node = new Vector(0., 0., 0.);
+  Walker->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name");
+  strcpy(Walker->Name, "1");
+  Walker->nr = 1;
+  points[0] = new BoundaryPointSet(Walker);
+  Walker = new TesselPoint;
+  Walker->node = new Vector(0., 1., 0.);
+  Walker->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name");
+  strcpy(Walker->Name, "2");
+  Walker->nr = 2;
+  points[1] = new BoundaryPointSet(Walker);
+  Walker = new TesselPoint;
+  Walker->node = new Vector(1., 0., 0.);
+  Walker->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name");
+  strcpy(Walker->Name, "3");
+  Walker->nr = 3;
+  points[2] = new BoundaryPointSet(Walker);
+
+  // create line
+  lines[0] = new BoundaryLineSet(points[0], points[1], 0);
+  lines[1] = new BoundaryLineSet(points[1], points[2], 1);
+  lines[2] = new BoundaryLineSet(points[0], points[2], 2);
+
+  // create triangle
+  triangle = new BoundaryTriangleSet(lines, 0);
+  triangle->GetNormalVector(Vector(0.,0.,1.));
+};
+
+
+void TesselationBoundaryTriangleTest::tearDown()
+{
+  delete(triangle);
+  MemoryUsageObserver::purgeInstance();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+};
+
+/** UnitTest for Tesselation::IsInnerPoint()
+ */
+void TesselationBoundaryTriangleTest::GetClosestPointOnPlaneTest()
+{
+  Vector TestIntersection;
+  Vector Point;
+
+  // simple test on y line
+  Point.Init(-1.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point.Init(-4.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( 16., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on x line
+  Point.Init(0.5,-1.,0.);
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.5,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point.Init(0.5,-6.,0.);
+  CPPUNIT_ASSERT_EQUAL( 36., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.5,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on slanted line
+  Point.Init(1.,1.,0.);
+  CPPUNIT_ASSERT_EQUAL( 0.5, triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.5,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point.Init(5.,5.,0.);
+  CPPUNIT_ASSERT_EQUAL( 40.5, triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.5,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on first node
+  Point.Init(-1.,-1.,0.);
+  CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on second node
+  Point.Init(0.,2.,0.);
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.,1.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on third node
+  Point.Init(2.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(1.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+};
+
+/** UnitTest for Tesselation::IsInnerPoint()
+ */
+void TesselationBoundaryTriangleTest::GetClosestPointOffPlaneTest()
+{
+  Vector TestIntersection;
+  Vector Point;
+
+  // straight down/up
+  Point.Init(1./3.,1./3.,+5.);
+  CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(1./3.,1./3.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point.Init(1./3.,1./3.,-5.);
+  CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(1./3.,1./3.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on y line
+  Point.Init(-1.,0.5,+2.);
+  CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point.Init(-1.,0.5,-3.);
+  CPPUNIT_ASSERT_EQUAL( 10., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on x line
+  Point.Init(0.5,-1.,+1.);
+  CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.5,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point.Init(0.5,-1.,-2.);
+  CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.5,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on slanted line
+  Point.Init(1.,1.,+3.);
+  CPPUNIT_ASSERT_EQUAL( 9.5, triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.5,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point.Init(1.,1.,-4.);
+  CPPUNIT_ASSERT_EQUAL( 16.5, triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.5,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on first node
+  Point.Init(-1.,-1.,5.);
+  CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on second node
+  Point.Init(0.,2.,5.);
+  CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(0.,1.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on third node
+  Point.Init(2.,0.,5.);
+  CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(&Point, &TestIntersection) );
+  Point.Init(1.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+};
+
+
+/********************************************** Main routine **************************************/
+
+int main(int argc, char **argv)
+{
+  // Get the top level suite from the registry
+  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+
+  // Adds the test to the list of test to run
+  CppUnit::TextUi::TestRunner runner;
+  runner.addTest( suite );
+
+  // Change the default outputter to a compiler error format outputter
+  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
+                                                       std::cerr ) );
+  // Run the tests.
+  bool wasSucessful = runner.run();
+
+  // Return error code 1 if the one of test failed.
+  return wasSucessful ? 0 : 1;
+};
Index: src/unittests/tesselation_boundarytriangleunittest.hpp
===================================================================
--- src/unittests/tesselation_boundarytriangleunittest.hpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
+++ src/unittests/tesselation_boundarytriangleunittest.hpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -0,0 +1,41 @@
+/*
+ * tesselation_boundarytriangleunittest.hpp
+ *
+ *  Created on: Jan 13, 2010
+ *      Author: heber
+ */
+
+#ifndef TESSELATION_BOUNDARYTRIANGLEUNITTEST_HPP_
+#define TESSELATION_BOUNDARYTRIANGLEUNITTEST_HPP_
+
+/*********************************************** includes ***********************************/
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "linkedcell.hpp"
+#include "tesselation.hpp"
+
+/********************************************** Test classes **************************************/
+
+class TesselationBoundaryTriangleTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( TesselationBoundaryTriangleTest) ;
+    CPPUNIT_TEST ( GetClosestPointOnPlaneTest );
+    CPPUNIT_TEST ( GetClosestPointOffPlaneTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void GetClosestPointOnPlaneTest();
+      void GetClosestPointOffPlaneTest();
+
+private:
+      class BoundaryTriangleSet *triangle;
+      class BoundaryLineSet *lines[3];
+      class BoundaryPointSet *points[3];
+      LinkedNodes Corners;
+};
+
+
+#endif /* TESSELATION_BOUNDARYTRIANGLEUNITTEST_HPP_ */
Index: src/unittests/tesselation_insideoutsideunittest.cpp
===================================================================
--- src/unittests/tesselation_insideoutsideunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
+++ src/unittests/tesselation_insideoutsideunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -0,0 +1,183 @@
+/*
+ * tesselation_insideoutsideunittest.cpp
+ *
+ *  Created on: Dec 28, 2009
+ *      Author: heber
+ */
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
+
+#include "defs.hpp"
+#include "tesselation.hpp"
+#include "tesselation_insideoutsideunittest.hpp"
+
+#define SPHERERADIUS 2.
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( TesselationInOutsideTest );
+
+
+void TesselationInOutsideTest::setUp()
+{
+  setVerbosity(2);
+
+  // create corners
+  class TesselPoint *Walker;
+  Walker = new TesselPoint;
+  Walker->node = new Vector(0., 0., 0.);
+  Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name");
+  strcpy(Walker->Name, "1");
+  Walker->nr = 1;
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->node = new Vector(0., 1., 0.);
+  Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name");
+  strcpy(Walker->Name, "2");
+  Walker->nr = 2;
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->node = new Vector(1., 0., 0.);
+  Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name");
+  strcpy(Walker->Name, "3");
+  Walker->nr = 3;
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->node = new Vector(1., 1., 0.);
+  Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name");
+  strcpy(Walker->Name, "4");
+  Walker->nr = 4;
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->node = new Vector(0., 0., 1.);
+  Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name");
+  strcpy(Walker->Name, "5");
+  Walker->nr = 5;
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->node = new Vector(0., 1., 1.);
+  Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name");
+  strcpy(Walker->Name, "6");
+  Walker->nr = 6;
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->node = new Vector(1., 0., 1.);
+  Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name");
+  strcpy(Walker->Name, "7");
+  Walker->nr = 7;
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->node = new Vector(1., 1., 1.);
+  Walker->Name = Malloc<char>(3, "TesselationInOutsideTest::setUp - *Name");
+  strcpy(Walker->Name, "8");
+  Walker->nr = 8;
+  Corners.push_back(Walker);
+
+  // create linkedcell
+  LinkedList = new LinkedCell(&Corners, 2.*SPHERERADIUS);
+
+  // create tesselation
+  TesselStruct = new Tesselation;
+  TesselStruct->FindStartingTriangle(SPHERERADIUS, LinkedList);
+
+  CandidateForTesselation *baseline = NULL;
+  BoundaryTriangleSet *T = NULL;
+  bool OneLoopWithoutSuccessFlag = true;
+  bool TesselationFailFlag = false;
+  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
+    // 2a. fill all new OpenLines
+    Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl;
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
+      Log() << Verbose(2) << *(Runner->second) << endl;
+
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
+      baseline = Runner->second;
+      if (baseline->pointlist.empty()) {
+        T = (((baseline->BaseLine->triangles.begin()))->second);
+        Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl;
+        TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one.
+      }
+    }
+
+    // 2b. search for smallest ShortestAngle among all candidates
+    double ShortestAngle = 4.*M_PI;
+    Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl;
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
+      Log() << Verbose(2) << *(Runner->second) << endl;
+
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
+      if (Runner->second->ShortestAngle < ShortestAngle) {
+        baseline = Runner->second;
+        ShortestAngle = baseline->ShortestAngle;
+        //Log() << Verbose(1) << "New best candidate is " << *baseline->BaseLine << " with point " << *baseline->point << " and angle " << baseline->ShortestAngle << endl;
+      }
+    }
+    if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty()))
+      OneLoopWithoutSuccessFlag = false;
+    else {
+      TesselStruct->AddCandidateTriangle(*baseline);
+    }
+  }
+};
+
+
+void TesselationInOutsideTest::tearDown()
+{
+  delete(LinkedList);
+  delete(TesselStruct);
+  for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
+    delete((*Runner)->node);
+    delete(*Runner);
+  }
+  Corners.clear();
+  MemoryUsageObserver::purgeInstance();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+};
+
+/** UnitTest for Tesselation::IsInnerPoint()
+ */
+void TesselationInOutsideTest::IsInnerPointTest()
+{
+  double n[3];
+  const double boundary = 2.;
+  const double step = 1.;
+
+  // go through the mesh 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) {
+        if ( ((n[0] >= 0.) && (n[1] >= 0.) && (n[2] >= 0.)) && ((n[0] <= 1.) && (n[1] <= 1.) && (n[2] <= 1.)))
+          CPPUNIT_ASSERT_EQUAL( true , TesselStruct->IsInnerPoint(Vector(n[0], n[1], n[2]), LinkedList) );
+        else
+          CPPUNIT_ASSERT_EQUAL( false , TesselStruct->IsInnerPoint(Vector(n[0], n[1], n[2]), LinkedList) );
+      }
+};
+
+/********************************************** Main routine **************************************/
+
+int main(int argc, char **argv)
+{
+  // Get the top level suite from the registry
+  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+
+  // Adds the test to the list of test to run
+  CppUnit::TextUi::TestRunner runner;
+  runner.addTest( suite );
+
+  // Change the default outputter to a compiler error format outputter
+  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
+                                                       std::cerr ) );
+  // Run the tests.
+  bool wasSucessful = runner.run();
+
+  // Return error code 1 if the one of test failed.
+  return wasSucessful ? 0 : 1;
+};
Index: src/unittests/tesselation_insideoutsideunittest.hpp
===================================================================
--- src/unittests/tesselation_insideoutsideunittest.hpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
+++ src/unittests/tesselation_insideoutsideunittest.hpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -0,0 +1,38 @@
+/*
+ * tesselation_insideoutsideunittest.hpp
+ *
+ *  Created on: Dec 28, 2009
+ *      Author: heber
+ */
+
+#ifndef TESSELATION_INSIDEOUTSIDEUNITTEST_HPP_
+#define TESSELATION_INSIDEOUTSIDEUNITTEST_HPP_
+
+/*********************************************** includes ***********************************/
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "linkedcell.hpp"
+#include "tesselation.hpp"
+
+/********************************************** Test classes **************************************/
+
+class TesselationInOutsideTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( TesselationInOutsideTest) ;
+    CPPUNIT_TEST ( IsInnerPointTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void IsInnerPointTest();
+
+private:
+      class Tesselation *TesselStruct;
+      LinkedNodes Corners;
+      class LinkedCell *LinkedList;
+};
+
+
+#endif /* TESSELATION_INSIDEOUTSIDEUNITTEST_HPP_ */
Index: src/unittests/tesselationunittest.cpp
===================================================================
--- src/unittests/tesselationunittest.cpp	(revision 1ca488f7e320046e400e980657d7c0d91e0356ae)
+++ src/unittests/tesselationunittest.cpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -12,4 +12,6 @@
 #include <cppunit/extensions/TestFactoryRegistry.h>
 #include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
 
 #include "defs.hpp"
@@ -30,18 +32,18 @@
   class TesselPoint *Walker;
   Walker = new TesselPoint;
-  Walker->node = new Vector(1., 0., 0.);
-  Walker->Name = new char[3];
+  Walker->node = new Vector(1., 0., -1.);
+  Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
   strcpy(Walker->Name, "1");
   Walker->nr = 1;
   Corners.push_back(Walker);
   Walker = new TesselPoint;
-  Walker->node = new Vector(-1., 1., 0.);
-  Walker->Name = new char[3];
+  Walker->node = new Vector(-1., 1., -1.);
+  Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
   strcpy(Walker->Name, "2");
   Walker->nr = 2;
   Corners.push_back(Walker);
   Walker = new TesselPoint;
-  Walker->node = new Vector(-1., -1., 0.);
-  Walker->Name = new char[3];
+  Walker->node = new Vector(-1., -1., -1.);
+  Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
   strcpy(Walker->Name, "3");
   Walker->nr = 3;
@@ -49,5 +51,5 @@
   Walker = new TesselPoint;
   Walker->node = new Vector(-1., 0., 1.);
-  Walker->Name = new char[3];
+  Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
   strcpy(Walker->Name, "4");
   Walker->nr = 4;
@@ -59,19 +61,35 @@
   // create tesselation
   TesselStruct = new Tesselation;
-  TesselStruct->PointsOnBoundary.clear();
-  TesselStruct->LinesOnBoundary.clear();
-  TesselStruct->TrianglesOnBoundary.clear();
+  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->PointsOnBoundary.empty() );
+  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->LinesOnBoundary.empty() );
+  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->TrianglesOnBoundary.empty() );
   TesselStruct->FindStartingTriangle(SPHERERADIUS, LinkedList);
-  bool flag = false;
 
-  LineMap::iterator baseline = TesselStruct->LinesOnBoundary.begin();
-  while (baseline != TesselStruct->LinesOnBoundary.end()) {
-    if (baseline->second->triangles.size() == 1) {
-      flag = TesselStruct->FindNextSuitableTriangle(*(baseline->second), *(((baseline->second->triangles.begin()))->second), SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one.
+  CandidateForTesselation *baseline = NULL;
+  BoundaryTriangleSet *T = NULL;
+  bool OneLoopWithoutSuccessFlag = true;
+  bool TesselationFailFlag = false;
+  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
+    // 2a. fill all new OpenLines
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
+      baseline = Runner->second;
+      if (baseline->pointlist.empty()) {
+        T = (((baseline->BaseLine->triangles.begin()))->second);
+        TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one.
+      }
     }
-    baseline++;
-    if ((baseline == TesselStruct->LinesOnBoundary.end()) && (flag)) {
-      baseline = TesselStruct->LinesOnBoundary.begin();   // restart if we reach end due to newly inserted lines
-      flag = false;
+
+    // 2b. search for smallest ShortestAngle among all candidates
+    double ShortestAngle = 4.*M_PI;
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
+      if (Runner->second->ShortestAngle < ShortestAngle) {
+        baseline = Runner->second;
+        ShortestAngle = baseline->ShortestAngle;
+      }
+    }
+    if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty()))
+      OneLoopWithoutSuccessFlag = false;
+    else {
+      TesselStruct->AddCandidateTriangle(*baseline);
     }
   }
@@ -84,33 +102,11 @@
   delete(TesselStruct);
   for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
-    delete[]((*Runner)->Name);
     delete((*Runner)->node);
     delete(*Runner);
   }
   Corners.clear();
-};
-
-/** UnitTest for Tesselation::IsInnerPoint()
- */
-void TesselationTest::IsInnerPointTest()
-{
-  // true inside points
-  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.,0.), LinkedList) );
-  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.5,0.,0.), LinkedList) );
-  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.5,0.), LinkedList) );
-  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.,0.5), LinkedList) );
-
-  // corners
-  for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++)
-    CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint((*Runner), LinkedList) );
-
-  // true outside points
-  CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(0.,5.,0.), LinkedList) );
-  CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(0.,0.,5.), LinkedList) );
-  CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(1.,1.,1.), LinkedList) );
-
-  // tricky point, there are three equally close triangles
-  CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(5.,0.,0.), LinkedList) );
-
+  MemoryUsageObserver::purgeInstance();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
 };
 
Index: src/unittests/tesselationunittest.hpp
===================================================================
--- src/unittests/tesselationunittest.hpp	(revision 1ca488f7e320046e400e980657d7c0d91e0356ae)
+++ src/unittests/tesselationunittest.hpp	(revision 2ededc23ca840f65c2141748eec08536adbb27d6)
@@ -21,5 +21,4 @@
 {
     CPPUNIT_TEST_SUITE( TesselationTest) ;
-    CPPUNIT_TEST ( IsInnerPointTest );
     CPPUNIT_TEST ( GetAllTrianglesTest );
     CPPUNIT_TEST ( ContainmentTest );
@@ -29,5 +28,4 @@
       void setUp();
       void tearDown();
-      void IsInnerPointTest();
       void GetAllTrianglesTest();
       void ContainmentTest();
