Index: src/unittests/ActOnAllUnitTest.cpp
===================================================================
--- src/unittests/ActOnAllUnitTest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/ActOnAllUnitTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -16,4 +16,8 @@
 #include "memoryallocator.hpp"
 #include "vector.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -40,4 +44,7 @@
 {
   VL.EmptyList();
+  // Ref was copy constructed, hence has to be cleaned, too!
+  Ref.EmptyList();
+  MemoryUsageObserver::purgeInstance();
 };
 
@@ -88,4 +95,6 @@
   VL.ActOnAll( (void (Vector::*)(const double ** const)) &Vector::Scale, (const double ** const)&inverses );
   CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
+  Free(factors);
+  Free(inverses);
 };
 
@@ -108,24 +117,2 @@
   }
 };
-
-
-/********************************************** 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/ActionSequenceTest.cpp
===================================================================
--- src/unittests/ActionSequenceTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/ActionSequenceTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,231 @@
+/*
+ * ActionSequenzTest.cpp
+ *
+ *  Created on: Dec 17, 2009
+ *      Author: crueger
+ */
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "unittests/ActionSequenceTest.hpp"
+#include "Actions/Action.hpp"
+#include "Actions/ActionSequence.hpp"
+#include "Actions/MakroAction.hpp"
+#include "Actions/ActionHistory.hpp"
+#include "Actions/ActionRegistry.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ActionSequenceTest );
+
+/* some neccessary stubs for tests */
+class canUndoActionStub : public Action
+{
+public:
+  canUndoActionStub(): Action("canUndoActionStub",false){}
+  virtual ~canUndoActionStub(){}
+
+  virtual Action::state_ptr performCall(){
+    return Action::success;
+  }
+  virtual Action::state_ptr performUndo(Action::state_ptr){
+    return Action::success;
+  }
+  virtual Action::state_ptr performRedo(Action::state_ptr){
+    return Action::success;
+  }
+  virtual bool canUndo(){
+    return true;
+  }
+  virtual bool shouldUndo(){
+    return true;
+  }
+};
+
+class cannotUndoActionStub : public Action
+{
+public:
+  cannotUndoActionStub() : Action("cannotUndoActionStub",false){}
+  virtual ~cannotUndoActionStub(){}
+
+  virtual Action::state_ptr performCall(){
+    return Action::success;
+  }
+  virtual Action::state_ptr performUndo(Action::state_ptr){
+    return Action::success;
+  }
+  virtual Action::state_ptr performRedo(Action::state_ptr){
+    return Action::success;
+  }
+  virtual bool canUndo(){
+    return false;
+  }
+  virtual bool shouldUndo(){
+   return true;
+  }
+};
+
+class wasCalledActionStub : public Action
+{
+public:
+  wasCalledActionStub() :
+      Action("wasCalledActionStub",false),
+      called(false)
+  {}
+  virtual ~wasCalledActionStub(){}
+
+  virtual Action::state_ptr performCall(){
+    called = true;
+    return Action::success;
+  }
+  virtual Action::state_ptr performUndo(Action::state_ptr){
+    called = false;
+    return Action::success;
+  }
+  virtual Action::state_ptr performRedo(Action::state_ptr){
+    called = true;
+    return Action::success;
+  }
+  virtual bool canUndo(){
+    return true;
+  }
+  virtual bool shouldUndo(){
+    return true;
+  }
+  bool wasCalled(){
+    return called;
+  }
+private:
+  bool called;
+};
+
+void ActionSequenceTest::setUp(){
+  ActionHistory::init();
+  // create some necessary stubs used in this test
+  positive1 = new canUndoActionStub();
+  positive2 = new canUndoActionStub();
+  negative1 = new cannotUndoActionStub();
+  negative2 = new cannotUndoActionStub();
+
+  shouldCall1 = new wasCalledActionStub();
+  shouldCall2 = new wasCalledActionStub();
+  shouldNotCall1 = new wasCalledActionStub();
+  shouldNotCall2 = new wasCalledActionStub();
+
+}
+
+void ActionSequenceTest::tearDown(){
+  delete positive1;
+  delete positive2;
+  delete negative1;
+  delete negative2;
+
+  delete shouldCall1;
+  delete shouldCall2;
+  delete shouldNotCall1;
+  delete shouldNotCall2;
+
+  ActionHistory::purgeInstance();
+  ActionRegistry::purgeInstance();
+}
+
+void ActionSequenceTest::canUndoTest(){
+  // first section:
+  {
+    // test some combinations
+    {
+      ActionSequence *sequence = new ActionSequence();
+      sequence->addAction(positive1);
+      sequence->addAction(positive2);
+      CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() );
+      delete sequence;
+    }
+    {
+      ActionSequence *sequence = new ActionSequence();
+      sequence->addAction(positive1);
+      sequence->addAction(negative2);
+      CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() );
+      delete sequence;
+    }
+    {
+      ActionSequence *sequence = new ActionSequence();
+      sequence->addAction(negative1);
+      sequence->addAction(positive2);
+      CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() );
+      delete sequence;
+    }
+    {
+      ActionSequence *sequence = new ActionSequence();
+      sequence->addAction(negative1);
+      sequence->addAction(negative2);
+      CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() );
+      delete sequence;
+    }
+  }
+
+  // second section:
+  {
+    // empty sequence can be undone
+    ActionSequence *sequence = new ActionSequence();
+    CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() );
+    // if only a positive action is contained it can be undone
+    sequence->addAction(positive1);
+    CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() );
+    // the single negative action should block the process
+    sequence->addAction(negative1);
+    CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() );
+    // after removing the negative action all is well again
+    sequence->removeLastAction();
+    CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() );
+    delete sequence;
+  }
+}
+
+void ActionSequenceTest::doesCallTest(){
+  ActionSequence *sequence = new ActionSequence();
+  sequence->addAction(shouldCall1);
+  sequence->addAction(shouldCall2);
+  sequence->addAction(shouldNotCall1);
+  sequence->addAction(shouldNotCall2);
+  sequence->removeLastAction();
+  sequence->removeLastAction();
+
+  sequence->callAll();
+
+  CPPUNIT_ASSERT_EQUAL(true,shouldCall1->wasCalled());
+  CPPUNIT_ASSERT_EQUAL(true,shouldCall2->wasCalled());
+  CPPUNIT_ASSERT_EQUAL(false,shouldNotCall1->wasCalled());
+  CPPUNIT_ASSERT_EQUAL(false,shouldNotCall2->wasCalled());
+
+  delete sequence;
+}
+
+void ActionSequenceTest::doesUndoTest(){
+  ActionSequence *sequence = new ActionSequence();
+  wasCalledActionStub *wasCalled1 = new wasCalledActionStub();
+  wasCalledActionStub *wasCalled2 = new wasCalledActionStub();
+  sequence->addAction(wasCalled1);
+  sequence->addAction(wasCalled2);
+
+  MakroAction act("Test MakroAction",sequence,false);
+
+  act.call();
+
+  CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled());
+  CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled());
+
+  ActionHistory::getInstance().undoLast();
+
+  CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled());
+  CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled());
+
+}
+
+
Index: src/unittests/ActionSequenceTest.hpp
===================================================================
--- src/unittests/ActionSequenceTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/ActionSequenceTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,43 @@
+/*
+ * ActionSequenzTest.hpp
+ *
+ *  Created on: Dec 17, 2009
+ *      Author: crueger
+ */
+
+#ifndef ACTIONSEQUENZTEST_HPP_
+#define ACTIONSEQUENZTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class Action;
+class wasCalledActionStub;
+
+class ActionSequenceTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( ActionSequenceTest) ;
+  CPPUNIT_TEST ( canUndoTest );
+  CPPUNIT_TEST ( doesCallTest );
+  CPPUNIT_TEST ( doesUndoTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void canUndoTest();
+  void doesCallTest();
+  void doesUndoTest();
+
+private:
+  Action *positive1;
+  Action *positive2;
+  Action *negative1;
+  Action *negative2;
+  wasCalledActionStub* shouldCall1;
+  wasCalledActionStub* shouldCall2;
+  wasCalledActionStub* shouldNotCall1;
+  wasCalledActionStub* shouldNotCall2;
+};
+
+#endif /* ACTIONSEQUENZTEST_HPP_ */
Index: src/unittests/AnalysisCorrelationToPointUnitTest.cpp
===================================================================
--- src/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/AnalysisCorrelationToPointUnitTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -17,4 +17,5 @@
 #include "AnalysisCorrelationToPointUnitTest.hpp"
 
+#include "World.hpp"
 #include "atom.hpp"
 #include "boundary.hpp"
@@ -24,4 +25,9 @@
 #include "periodentafel.hpp"
 #include "tesselation.hpp"
+#include "World.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -51,22 +57,22 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::getInstance().getPeriode();
   tafel->AddElement(hydrogen);
 
   // construct molecule (tetraeder of hydrogens)
-  TestMolecule = new molecule(tafel);
-  Walker = new atom();
+  TestMolecule = World::getInstance().createMolecule();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(1., 0., 1. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(0., 1., 1. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(1., 1., 0. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(0., 0., 0. );
@@ -76,7 +82,7 @@
   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
 
-  TestList = new MoleculeListClass;
+  TestList = World::getInstance().getMolecules();
+  TestList->insert(TestMolecule);
   TestMolecule->ActiveFlag = true;
-  TestList->insert(TestMolecule);
 
   // init point
@@ -97,10 +103,8 @@
     delete(binmap);
 
-  // remove
-  delete(TestList);
-  // note that all the atoms are cleaned by TestMolecule
   delete(point);
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::purgeInstance();
+  MemoryUsageObserver::purgeInstance();
+  logger::purgeInstance();
 };
 
@@ -140,23 +144,2 @@
 
 };
-
-/********************************************** 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/AnalysisCorrelationToSurfaceUnitTest.cpp
===================================================================
--- src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -17,4 +17,5 @@
 #include "AnalysisCorrelationToSurfaceUnitTest.hpp"
 
+#include "World.hpp"
 #include "atom.hpp"
 #include "boundary.hpp"
@@ -24,4 +25,11 @@
 #include "periodentafel.hpp"
 #include "tesselation.hpp"
+#include "World.hpp"
+
+#include "Helpers/Assert.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -32,4 +40,6 @@
 void AnalysisCorrelationToSurfaceUnitTest::setUp()
 {
+  ASSERT_DO(Assert::Throw);
+
   atom *Walker = NULL;
 
@@ -55,23 +65,23 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::getInstance().getPeriode();
   tafel->AddElement(hydrogen);
   tafel->AddElement(carbon);
 
   // construct molecule (tetraeder of hydrogens) base
-  TestSurfaceMolecule = new molecule(tafel);
-  Walker = new atom();
+  TestSurfaceMolecule = World::getInstance().createMolecule();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(1., 0., 1. );
   TestSurfaceMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(0., 1., 1. );
   TestSurfaceMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(1., 1., 0. );
   TestSurfaceMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(0., 0., 0. );
@@ -81,5 +91,5 @@
   CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->AtomCount, 4 );
 
-  TestList = new MoleculeListClass;
+  TestList = World::getInstance().getMolecules();
   TestSurfaceMolecule->ActiveFlag = true;
   TestList->insert(TestSurfaceMolecule);
@@ -91,19 +101,19 @@
 
   // add outer atoms
-  TestMolecule = new molecule(tafel);
-  Walker = new atom();
+  TestMolecule = World::getInstance().createMolecule();
+  Walker = World::getInstance().createAtom();
   Walker->type = carbon;
   Walker->node->Init(4., 0., 4. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = carbon;
   Walker->node->Init(0., 4., 4. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = carbon;
   Walker->node->Init(4., 4., 0. );
   TestMolecule->AddAtom(Walker);
   // add inner atoms
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = carbon;
   Walker->node->Init(0.5, 0.5, 0.5 );
@@ -126,11 +136,10 @@
     delete(binmap);
 
-  // remove
-  delete(TestList);
   delete(Surface);
   // note that all the atoms are cleaned by TestMolecule
   delete(LC);
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::purgeInstance();
+  MemoryUsageObserver::purgeInstance();
+  logger::purgeInstance();
 };
 
@@ -227,23 +236,2 @@
   CPPUNIT_ASSERT_EQUAL( 1, tester->second );
 };
-
-/********************************************** 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/AnalysisPairCorrelationUnitTest.cpp
===================================================================
--- src/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/AnalysisPairCorrelationUnitTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -17,4 +17,5 @@
 #include "AnalysisPairCorrelationUnitTest.hpp"
 
+#include "World.hpp"
 #include "atom.hpp"
 #include "boundary.hpp"
@@ -24,4 +25,9 @@
 #include "periodentafel.hpp"
 #include "tesselation.hpp"
+#include "World.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -50,22 +56,22 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::getInstance().getPeriode();
   tafel->AddElement(hydrogen);
 
   // construct molecule (tetraeder of hydrogens)
-  TestMolecule = new molecule(tafel);
-  Walker = new atom();
+  TestMolecule = World::getInstance().createMolecule();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(1., 0., 1. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(0., 1., 1. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(1., 1., 0. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(0., 0., 0. );
@@ -75,5 +81,5 @@
   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
 
-  TestList = new MoleculeListClass;
+  TestList = World::getInstance().getMolecules();
   TestMolecule->ActiveFlag = true;
   TestList->insert(TestMolecule);
@@ -93,9 +99,9 @@
     delete(binmap);
 
-  // remove
-  delete(TestList);
   // note that all the atoms are cleaned by TestMolecule
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::purgeInstance();
+  MemoryUsageObserver::purgeInstance();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
 };
 
@@ -132,23 +138,2 @@
   CPPUNIT_ASSERT_EQUAL( 6, tester->second );
 };
-
-/********************************************** 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/AtomDescriptorTest.cpp
===================================================================
--- src/unittests/AtomDescriptorTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/AtomDescriptorTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,157 @@
+/*
+ * DescriptorUnittest.cpp
+ *
+ *  Created on: Feb 9, 2010
+ *      Author: crueger
+ */
+
+#include "AtomDescriptorTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+
+#include <Descriptors/AtomDescriptor.hpp>
+#include <Descriptors/AtomIdDescriptor.hpp>
+
+#include "World.hpp"
+#include "atom.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( AtomDescriptorTest );
+
+// set up and tear down
+void AtomDescriptorTest::setUp(){
+  World::getInstance();
+  for(int i=0;i<ATOM_COUNT;++i){
+    atoms[i]= World::getInstance().createAtom();
+    atomIds[i]= atoms[i]->getId();
+  }
+}
+
+void AtomDescriptorTest::tearDown(){
+  World::purgeInstance();
+}
+
+// some helper functions
+static bool hasAllAtoms(std::vector<atom*> atoms,atomId_t ids[ATOM_COUNT], std::set<atomId_t> excluded = std::set<atomId_t>()){
+  for(int i=0;i<ATOM_COUNT;++i){
+    atomId_t id = ids[i];
+    if(!excluded.count(id)){
+      std::vector<atom*>::iterator iter;
+      bool res=false;
+      for(iter=atoms.begin();iter!=atoms.end();++iter){
+        res |= (*iter)->getId() == id;
+      }
+      if(!res) {
+        cout << "Atom " << id << " missing in returned list" << endl;
+        return false;
+      }
+    }
+  }
+  return true;
+}
+
+static bool hasNoDuplicateAtoms(std::vector<atom*> atoms){
+  std::set<atomId_t> found;
+  std::vector<atom*>::iterator iter;
+  for(iter=atoms.begin();iter!=atoms.end();++iter){
+    int id = (*iter)->getId();
+    if(found.count(id))
+      return false;
+    found.insert(id);
+  }
+  return true;
+}
+
+
+void AtomDescriptorTest::AtomBaseSetsTest(){
+  std::vector<atom*> allAtoms = World::getInstance().getAllAtoms(AllAtoms());
+  CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(allAtoms,atomIds));
+  CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(allAtoms));
+
+  std::vector<atom*> noAtoms = World::getInstance().getAllAtoms(NoAtoms());
+  CPPUNIT_ASSERT_EQUAL( true , noAtoms.empty());
+}
+void AtomDescriptorTest::AtomIdTest(){
+  // test Atoms from boundaries and middle of the set
+  atom* testAtom;
+  testAtom = World::getInstance().getAtom(AtomById(atomIds[0]));
+  CPPUNIT_ASSERT(testAtom);
+  CPPUNIT_ASSERT_EQUAL( atomIds[0], testAtom->getId());
+  testAtom = World::getInstance().getAtom(AtomById(atomIds[ATOM_COUNT/2]));
+  CPPUNIT_ASSERT(testAtom);
+  CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT/2], testAtom->getId());
+  testAtom = World::getInstance().getAtom(AtomById(atomIds[ATOM_COUNT-1]));
+  CPPUNIT_ASSERT(testAtom);
+  CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT-1], testAtom->getId());
+
+  // find some ID that has not been created
+  atomId_t outsideId=0;
+  bool res = false;
+  for(outsideId=0;!res;++outsideId) {
+    res = true;
+    for(int i = 0; i < ATOM_COUNT; ++i){
+      res &= atomIds[i]!=outsideId;
+    }
+  }
+  // test from outside of set
+  testAtom = World::getInstance().getAtom(AtomById(outsideId));
+  CPPUNIT_ASSERT(!testAtom);
+}
+void AtomDescriptorTest::AtomCalcTest(){
+  // test some elementary set operations
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()||NoAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()||AllAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()&&AllAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()&&NoAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(!AllAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(!NoAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
+  }
+  // exclude and include some atoms
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()&&(!AtomById(atomIds[ATOM_COUNT/2])));
+    std::set<atomId_t> excluded;
+    excluded.insert(atomIds[ATOM_COUNT/2]);
+    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds,excluded));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
+    CPPUNIT_ASSERT_EQUAL( (size_t)(ATOM_COUNT-1), testAtoms.size());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()||(AtomById(atomIds[ATOM_COUNT/2])));
+    CPPUNIT_ASSERT_EQUAL( (size_t)1, testAtoms.size());
+    CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT/2], testAtoms[0]->getId());
+  }
+}
Index: src/unittests/AtomDescriptorTest.hpp
===================================================================
--- src/unittests/AtomDescriptorTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/AtomDescriptorTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,40 @@
+/*
+ * AtomDescriptorTest.hpp
+ *
+ *  Created on: Feb 9, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMDESCRIPTORTEST_HPP_
+#define ATOMDESCRIPTORTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "types.hpp"
+
+#define ATOM_COUNT (10)
+
+class atom;
+
+class AtomDescriptorTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( AtomDescriptorTest );
+  CPPUNIT_TEST ( AtomBaseSetsTest );
+  CPPUNIT_TEST ( AtomIdTest );
+  CPPUNIT_TEST ( AtomCalcTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void AtomBaseSetsTest();
+  void AtomIdTest();
+  void AtomCalcTest();
+
+private:
+  atom *atoms [ATOM_COUNT];
+  atomId_t atomIds [ATOM_COUNT];
+};
+
+#endif /* ATOMDESCRIPTORTEST_HPP_ */
Index: src/unittests/CacheableTest.cpp
===================================================================
--- src/unittests/CacheableTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/CacheableTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,83 @@
+/*
+ * CacheableTest.cpp
+ *
+ *  Created on: Feb 2, 2010
+ *      Author: crueger
+ */
+
+#include "CacheableTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <boost/bind.hpp>
+
+#include "Patterns/Cacheable.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( CacheableTest );
+
+class threeNumbers : public Observable {
+public:
+  int x;
+  int y;
+  int z;
+  Cacheable<int> sum;
+  bool hasRecalced;
+
+  void setX(int _x){
+    OBSERVE;
+    x = _x;
+  }
+
+  void setY
+  (int _y){
+    OBSERVE;
+    y = _y;
+  }
+
+  void setZ(int _z){
+    OBSERVE;
+    z = _z;
+  }
+
+  int calcSum(){
+    hasRecalced = true;
+    return x+y+z;
+  }
+
+  threeNumbers(int _x,int _y, int _z) :
+    x(_x),y(_y),z(_z),
+    sum(this,boost::bind(&threeNumbers::calcSum,this)),
+    hasRecalced(false)
+  {}
+};
+
+
+
+
+void CacheableTest::setUp(){
+  numbers = new threeNumbers(1,2,3);
+}
+
+void CacheableTest::tearDown(){
+  delete numbers;
+}
+
+void CacheableTest::doesRecalcTest()
+{
+  CPPUNIT_ASSERT_EQUAL( 6, *(numbers->sum));
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+  numbers->hasRecalced=false;
+  numbers->setX(4);
+  CPPUNIT_ASSERT_EQUAL( false, numbers->hasRecalced);
+  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+}
Index: src/unittests/CacheableTest.hpp
===================================================================
--- src/unittests/CacheableTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/CacheableTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,31 @@
+/*
+ * CacheableTest.hpp
+ *
+ *  Created on: Feb 2, 2010
+ *      Author: crueger
+ */
+
+#ifndef CACHEABLETEST_HPP_
+#define CACHEABLETEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+// stub classes
+class threeNumbers;
+
+class CacheableTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( CacheableTest );
+  CPPUNIT_TEST ( doesRecalcTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void doesRecalcTest();
+  threeNumbers *numbers;
+};
+
+#endif /* CACHEABLETEST_HPP_ */
Index: src/unittests/CountBondsUnitTest.cpp
===================================================================
--- src/unittests/CountBondsUnitTest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/CountBondsUnitTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -24,5 +24,10 @@
 #include "molecule.hpp"
 #include "periodentafel.hpp"
+#include "World.hpp"
 #include "CountBondsUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -35,4 +40,6 @@
 {
   atom *Walker = NULL;
+  BG = NULL;
+  filename = NULL;
 
   // init private all pointers to zero
@@ -57,38 +64,39 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::getInstance().getPeriode();
   tafel->AddElement(hydrogen);
   tafel->AddElement(oxygen);
 
   // construct molecule (water molecule)
-  molecules = new MoleculeListClass;
-  TestMolecule1 = new molecule(tafel);
-  Walker = new atom();
+  TestMolecule1 = World::getInstance().createMolecule();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(-0.2418, 0.9350, 0. );
   TestMolecule1->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(0.9658, 0., 0. );
   TestMolecule1->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = oxygen;
   Walker->node->Init(0., 0., 0. );
   TestMolecule1->AddAtom(Walker);
-  molecules->insert(TestMolecule1);
-
-  TestMolecule2 = new molecule(tafel);
-  Walker = new atom();
+
+  TestMolecule2 = World::getInstance().createMolecule();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(-0.2418, 0.9350, 0. );
   TestMolecule2->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(0.9658, 0., 0. );
   TestMolecule2->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = oxygen;
   Walker->node->Init(0., 0., 0. );
   TestMolecule2->AddAtom(Walker);
+
+  molecules = World::getInstance().getMolecules();
+  molecules->insert(TestMolecule1);
   molecules->insert(TestMolecule2);
 
@@ -117,9 +125,6 @@
   delete(BG);
 
-  // remove molecule
-  delete(molecules);
-  // note that all the atoms are cleaned by TestMolecule
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::purgeInstance();
+  MemoryUsageObserver::purgeInstance();
 };
 
@@ -232,26 +237,4 @@
   TestMolecule2->Scale((const double ** const)&mirror);
 
-  delete(mirror);
-};
-
-
-/********************************************** 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;
-};
+  delete[](mirror);
+};
Index: src/unittests/LinkedCellUnitTest.cpp
===================================================================
--- src/unittests/LinkedCellUnitTest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/LinkedCellUnitTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -22,4 +22,9 @@
 #include "periodentafel.hpp"
 #include "LinkedCellUnitTest.hpp"
+#include "World.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -46,13 +51,13 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::getInstance().getPeriode();
   tafel->AddElement(hydrogen);
 
   // construct molecule (water molecule)
-  TestMolecule = new molecule(tafel);
+  TestMolecule = World::getInstance().createMolecule();
   for (double x=0.5;x<3;x+=1.)
     for (double y=0.5;y<3;y+=1.)
       for (double z=0.5;z<3;z+=1.) {
-        Walker = new atom();
+        Walker = World::getInstance().createAtom();
         Walker->type = hydrogen;
         Walker->node->Init(x, y, z );
@@ -73,8 +78,6 @@
 {
   delete(LC);
-  delete(TestMolecule);
-  // note that all the atoms are cleaned by TestMolecule
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::purgeInstance();
+  MemoryUsageObserver::purgeInstance();
 };
 
@@ -201,18 +204,18 @@
 
   // check internal vectors, returns false, because this atom is not in LC-list!
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->Name = Malloc<char>(6, "LinkedCellTest::SetIndexToNodeTest - Walker");
   strcpy(Walker->Name, "test");
   Walker->x.Init(1,1,1);
   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) );
-  delete(Walker);
+  World::getInstance().destroyAtom(Walker);
 
   // check out of bounds vectors
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->Name = Malloc<char>(6, "LinkedCellTest::SetIndexToNodeTest - Walker");
   strcpy(Walker->Name, "test");
   Walker->x.Init(0,-1,0);
   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) );
-  delete(Walker);
+  World::getInstance().destroyAtom(Walker);
 };
 
@@ -368,24 +371,2 @@
   delete(ListOfPoints);
 };
-
-/********************************************** 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/Makefile.am
===================================================================
--- src/unittests/Makefile.am	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/Makefile.am	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -3,4 +3,7 @@
 AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl
 AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
+
+MENUTESTS = \
+  ActionSequenceTest
 
 TESTS = \
@@ -10,5 +13,8 @@
   AnalysisCorrelationToSurfaceUnitTest \
   AnalysisPairCorrelationUnitTest \
+  atomsCalculationTest \
+  AtomDescriptorTest \
   BondGraphUnitTest \
+  CacheableTest \
   CountBondsUnitTest \
   GSLMatrixSymmetricUnitTest \
@@ -20,81 +26,181 @@
   ListOfBondsUnitTest \
   LogUnitTest \
+  manipulateAtomsTest \
   MemoryUsageObserverUnitTest \
   MemoryAllocatorUnitTest \
+  MoleculeDescriptorTest \
+  ObserverTest \
+  SingletonTest \
   StackClassUnitTest \
   TesselationUnitTest \
   Tesselation_BoundaryTriangleUnitTest \
   Tesselation_InOutsideUnitTest \
-  VectorUnitTest
+  VectorUnitTest \
+  ${MENUTESTS}
   
-check_PROGRAMS = $(TESTS)
-noinst_PROGRAMS = $(TESTS)
-
-ActOnAllUnitTest_SOURCES = ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
-ActOnAllUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
-
-AnalysisBondsUnitTests_SOURCES = analysisbondsunittest.cpp analysisbondsunittest.hpp
-AnalysisBondsUnitTests_LDADD = ../libmolecuilder.a ../libgslwrapper.a
-
-AnalysisCorrelationToPointUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToPointUnitTest.cpp AnalysisCorrelationToPointUnitTest.hpp
-AnalysisCorrelationToPointUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
-
-AnalysisCorrelationToSurfaceUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToSurfaceUnitTest.cpp AnalysisCorrelationToSurfaceUnitTest.hpp
-AnalysisCorrelationToSurfaceUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
-
-AnalysisPairCorrelationUnitTest_SOURCES = analysis_correlation.hpp AnalysisPairCorrelationUnitTest.cpp AnalysisPairCorrelationUnitTest.hpp
-AnalysisPairCorrelationUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
-
-BondGraphUnitTest_SOURCES = bondgraphunittest.cpp bondgraphunittest.hpp
-BondGraphUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
-
-CountBondsUnitTest_SOURCES = CountBondsUnitTest.cpp CountBondsUnitTest.hpp
-CountBondsUnitTest_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 ../libgslwrapper.a
-
-LinearSystemOfEquationsUnitTest_SOURCES = linearsystemofequationsunittest.cpp linearsystemofequationsunittest.hpp
-LinearSystemOfEquationsUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
-
-LinkedCellUnitTest_SOURCES = LinkedCellUnitTest.cpp LinkedCellUnitTest.hpp 
-LinkedCellUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
-
-ListOfBondsUnitTest_SOURCES = listofbondsunittest.cpp listofbondsunittest.hpp
-ListOfBondsUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
-
-LogUnitTest_SOURCES = logunittest.cpp logunittest.hpp 
-LogUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
-
-MemoryAllocatorUnitTest_SOURCES = memoryallocatorunittest.cpp memoryallocatorunittest.hpp 
-MemoryAllocatorUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
-
-MemoryUsageObserverUnitTest_SOURCES = memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp 
-MemoryUsageObserverUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
-
-StackClassUnitTest_SOURCES = stackclassunittest.cpp stackclassunittest.hpp
-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 ../libgslwrapper.a
-
+  
+check_PROGRAMS = $(TESTS) 
+noinst_PROGRAMS = $(TESTS) TestRunner
+
+GSLLIBS = ../libgslwrapper.a
+ALLLIBS = ../libmolecuilder.a ${GSLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB}
+
+TESTSOURCES = \
+  ActOnAllUnitTest.cpp \
+  ActionSequenceTest.cpp \
+  analysisbondsunittest.cpp \
+  AnalysisCorrelationToPointUnitTest.cpp \
+  AnalysisCorrelationToSurfaceUnitTest.cpp  \
+  AnalysisPairCorrelationUnitTest.cpp \
+  AtomDescriptorTest.cpp \
+  atomsCalculationTest.cpp \
+  bondgraphunittest.cpp \
+  CacheableTest.cpp \
+  CountBondsUnitTest.cpp \
+  gslmatrixsymmetricunittest.cpp \
+  gslmatrixunittest.cpp \
+  gslvectorunittest.cpp \
+  infounittest.cpp \
+  linearsystemofequationsunittest.cpp \
+  LinkedCellUnitTest.cpp \
+  listofbondsunittest.cpp \
+  logunittest.cpp \
+  manipulateAtomsTest.cpp \
+  memoryallocatorunittest.cpp  \
+  memoryusageobserverunittest.cpp \
+  MoleculeDescriptorTest.cpp \
+  ObserverTest.cpp \
+  SingletonTest.cpp \
+  stackclassunittest.cpp \
+  tesselationunittest.cpp \
+  tesselation_boundarytriangleunittest.cpp \
+  tesselation_insideoutsideunittest.cpp \
+  vectorunittest.cpp
+
+TESTHEADERS = \
+  ActOnAllUnitTest.hpp \
+  ActionSequenceTest.hpp \
+  analysisbondsunittest.hpp \
+  AnalysisCorrelationToPointUnitTest.hpp \
+  AnalysisCorrelationToSurfaceUnitTest.hpp  \
+  AnalysisPairCorrelationUnitTest.hpp \
+  AtomDescriptorTest.hpp \
+  atomsCalculationTest.hpp \
+  bondgraphunittest.hpp \
+  CacheableTest.hpp \
+  CountBondsUnitTest.hpp \
+  gslmatrixsymmetricunittest.hpp \
+  gslmatrixunittest.hpp \
+  gslvectorunittest.hpp \
+  infounittest.hpp \
+  linearsystemofequationsunittest.hpp \
+  LinkedCellUnitTest.hpp \
+  listofbondsunittest.hpp \
+  logunittest.hpp \
+  manipulateAtomsTest.hpp \
+  memoryallocatorunittest.hpp  \
+  memoryusageobserverunittest.hpp \
+  MoleculeDescriptorTest.hpp \
+  ObserverTest.hpp \
+  SingletonTest.hpp \
+  stackclassunittest.hpp \
+  tesselationunittest.hpp \
+  tesselation_boundarytriangleunittest.hpp \
+  tesselation_insideoutsideunittest.hpp \
+  vectorunittest.hpp
+  
+
+ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
+ActOnAllUnitTest_LDADD = ${ALLLIBS}
+
+AnalysisBondsUnitTests_SOURCES = UnitTestMain.cpp analysisbondsunittest.cpp analysisbondsunittest.hpp
+AnalysisBondsUnitTests_LDADD = ${ALLLIBS}
+
+AnalysisCorrelationToPointUnitTest_SOURCES = UnitTestMain.cpp analysis_correlation.hpp AnalysisCorrelationToPointUnitTest.cpp AnalysisCorrelationToPointUnitTest.hpp
+AnalysisCorrelationToPointUnitTest_LDADD = ${ALLLIBS}
+
+AnalysisCorrelationToSurfaceUnitTest_SOURCES = UnitTestMain.cpp analysis_correlation.hpp AnalysisCorrelationToSurfaceUnitTest.cpp AnalysisCorrelationToSurfaceUnitTest.hpp
+AnalysisCorrelationToSurfaceUnitTest_LDADD = ${ALLLIBS}
+
+AnalysisPairCorrelationUnitTest_SOURCES = UnitTestMain.cpp analysis_correlation.hpp AnalysisPairCorrelationUnitTest.cpp AnalysisPairCorrelationUnitTest.hpp
+AnalysisPairCorrelationUnitTest_LDADD = ${ALLLIBS}
+
+atomsCalculationTest_SOURCES = UnitTestMain.cpp atomsCalculationTest.cpp atomsCalculationTest.hpp
+atomsCalculationTest_LDADD = ${ALLLIBS}
+
+BondGraphUnitTest_SOURCES = UnitTestMain.cpp bondgraphunittest.cpp bondgraphunittest.hpp
+BondGraphUnitTest_LDADD = ${ALLLIBS}
+
+CountBondsUnitTest_SOURCES = UnitTestMain.cpp CountBondsUnitTest.cpp CountBondsUnitTest.hpp
+CountBondsUnitTest_LDADD = ${ALLLIBS}
+
+GSLMatrixSymmetricUnitTest_SOURCES = UnitTestMain.cpp gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp
+GSLMatrixSymmetricUnitTest_LDADD = ${GSLLIBS}
+
+GSLMatrixUnitTest_SOURCES = UnitTestMain.cpp gslmatrixunittest.cpp gslmatrixunittest.hpp
+GSLMatrixUnitTest_LDADD = ${GSLLIBS}
+
+GSLVectorUnitTest_SOURCES = UnitTestMain.cpp gslvectorunittest.cpp gslvectorunittest.hpp
+GSLVectorUnitTest_LDADD = ${GSLLIBS}
+
+InfoUnitTest_SOURCES = UnitTestMain.cpp infounittest.cpp infounittest.hpp
+InfoUnitTest_LDADD = ${ALLLIBS}
+
+LinearSystemOfEquationsUnitTest_SOURCES = UnitTestMain.cpp linearsystemofequationsunittest.cpp linearsystemofequationsunittest.hpp
+LinearSystemOfEquationsUnitTest_LDADD = ${ALLLIBS}
+
+LinkedCellUnitTest_SOURCES = UnitTestMain.cpp LinkedCellUnitTest.cpp LinkedCellUnitTest.hpp 
+LinkedCellUnitTest_LDADD = ${ALLLIBS}
+
+ListOfBondsUnitTest_SOURCES = UnitTestMain.cpp listofbondsunittest.cpp listofbondsunittest.hpp
+ListOfBondsUnitTest_LDADD = ${ALLLIBS}
+
+LogUnitTest_SOURCES = UnitTestMain.cpp logunittest.cpp logunittest.hpp 
+LogUnitTest_LDADD = ${ALLLIBS}
+
+MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp 
+MemoryAllocatorUnitTest_LDADD = ${ALLLIBS}
+
+MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp 
+MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS}
+
+MoleculeDescriptorTest_SOURCES = UnitTestMain.cpp MoleculeDescriptorTest.cpp MoleculeDescriptorTest.hpp
+MoleculeDescriptorTest_LDADD = ${ALLLIBS}
+
+SingletonTest_SOURCES = UnitTestMain.cpp SingletonTest.cpp SingletonTest.hpp
+SingletonTest_LDADD = $(BOOST_LIB) ${BOOST_THREAD_LIB}
+
+StackClassUnitTest_SOURCES = UnitTestMain.cpp stackclassunittest.cpp stackclassunittest.hpp
+StackClassUnitTest_LDADD = ${ALLLIBS}
+
+TesselationUnitTest_SOURCES = UnitTestMain.cpp tesselationunittest.cpp tesselationunittest.hpp
+TesselationUnitTest_LDADD = ${ALLLIBS}
+
+Tesselation_BoundaryTriangleUnitTest_SOURCES = UnitTestMain.cpp tesselation_boundarytriangleunittest.cpp tesselation_boundarytriangleunittest.hpp
+Tesselation_BoundaryTriangleUnitTest_LDADD = ${ALLLIBS}
+
+Tesselation_InOutsideUnitTest_SOURCES = UnitTestMain.cpp tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp
+Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS}
+
+VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp 
+VectorUnitTest_LDADD = ${ALLLIBS}
+
+ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp
+ActionSequenceTest_LDADD = ${ALLLIBS}
+
+ObserverTest_SOURCES = UnitTestMain.cpp ObserverTest.cpp ObserverTest.hpp
+ObserverTest_LDADD = ${ALLLIBS}
+
+CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp
+CacheableTest_LDADD = ${ALLLIBS}
+
+AtomDescriptorTest_SOURCES = UnitTestMain.cpp AtomDescriptorTest.cpp AtomDescriptorTest.hpp
+AtomDescriptorTest_LDADD = ${ALLLIBS}
+
+manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp
+manipulateAtomsTest_LDADD = ${ALLLIBS}
+
+TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS)
+TestRunner_LDADD = ${ALLLIBS}
 
 #AUTOMAKE_OPTIONS = parallel-tests
Index: src/unittests/MoleculeDescriptorTest.cpp
===================================================================
--- src/unittests/MoleculeDescriptorTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/MoleculeDescriptorTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,158 @@
+/*
+ * MoleculeDescriptorTest.cpp
+ *
+ *  Created on: Mar 4, 2010
+ *      Author: crueger
+ */
+
+#include "MoleculeDescriptorTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+
+#include <Descriptors/MoleculeDescriptor.hpp>
+#include <Descriptors/MoleculeIdDescriptor.hpp>
+
+#include "World.hpp"
+#include "molecule.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( MoleculeDescriptorTest );
+
+// set up and tear down
+void MoleculeDescriptorTest::setUp(){
+  World::getInstance();
+  for(int i=0;i<MOLECULE_COUNT;++i){
+    molecules[i]= World::getInstance().createMolecule();
+    moleculeIds[i]= molecules[i]->getId();
+  }
+}
+
+void MoleculeDescriptorTest::tearDown(){
+  World::purgeInstance();
+}
+
+// some helper functions
+static bool hasAllMolecules(std::vector<molecule*> molecules,moleculeId_t ids[MOLECULE_COUNT], std::set<moleculeId_t> excluded = std::set<moleculeId_t>()){
+  for(int i=0;i<MOLECULE_COUNT;++i){
+    moleculeId_t id = ids[i];
+    if(!excluded.count(id)){
+      std::vector<molecule*>::iterator iter;
+      bool res=false;
+      for(iter=molecules.begin();iter!=molecules.end();++iter){
+        res |= (*iter)->getId() == id;
+      }
+      if(!res) {
+        cout << "Molecule " << id << " missing in returned list" << endl;
+        return false;
+      }
+    }
+  }
+  return true;
+}
+
+static bool hasNoDuplicateMolecules(std::vector<molecule*> molecules){
+  std::set<moleculeId_t> found;
+  std::vector<molecule*>::iterator iter;
+  for(iter=molecules.begin();iter!=molecules.end();++iter){
+    int id = (*iter)->getId();
+    if(found.count(id))
+      return false;
+    found.insert(id);
+  }
+  return true;
+}
+
+
+void MoleculeDescriptorTest::MoleculeBaseSetsTest(){
+  std::vector<molecule*> allMolecules = World::getInstance().getAllMolecules(AllMolecules());
+  CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(allMolecules,moleculeIds));
+  CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(allMolecules));
+
+  std::vector<molecule*> noMolecules = World::getInstance().getAllMolecules(NoMolecules());
+  CPPUNIT_ASSERT_EQUAL( true , noMolecules.empty());
+}
+void MoleculeDescriptorTest::MoleculeIdTest(){
+  // test Molecules from boundaries and middle of the set
+  molecule* testMolecule;
+  testMolecule = World::getInstance().getMolecule(MoleculeById(moleculeIds[0]));
+  CPPUNIT_ASSERT(testMolecule);
+  CPPUNIT_ASSERT_EQUAL( moleculeIds[0], testMolecule->getId());
+  testMolecule = World::getInstance().getMolecule(MoleculeById(moleculeIds[MOLECULE_COUNT/2]));
+  CPPUNIT_ASSERT(testMolecule);
+  CPPUNIT_ASSERT_EQUAL( moleculeIds[MOLECULE_COUNT/2], testMolecule->getId());
+  testMolecule = World::getInstance().getMolecule(MoleculeById(moleculeIds[MOLECULE_COUNT-1]));
+  CPPUNIT_ASSERT(testMolecule);
+  CPPUNIT_ASSERT_EQUAL( moleculeIds[MOLECULE_COUNT-1], testMolecule->getId());
+
+  // find some ID that has not been created
+  moleculeId_t outsideId=0;
+  bool res = false;
+  for(outsideId=0;!res;++outsideId) {
+    res = true;
+    for(int i = 0; i < MOLECULE_COUNT; ++i){
+      res &= moleculeIds[i]!=outsideId;
+    }
+  }
+  // test from outside of set
+  testMolecule = World::getInstance().getMolecule(MoleculeById(outsideId));
+  CPPUNIT_ASSERT(!testMolecule);
+}
+void MoleculeDescriptorTest::MoleculeCalcTest(){
+  // test some elementary set operations
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()||NoMolecules());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
+  }
+
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()||AllMolecules());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
+  }
+
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()&&AllMolecules());
+    CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty());
+  }
+
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()&&NoMolecules());
+    CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty());
+  }
+
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(!AllMolecules());
+    CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty());
+  }
+
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(!NoMolecules());
+    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
+  }
+
+  // exclude and include some molecules
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()&&(!MoleculeById(moleculeIds[MOLECULE_COUNT/2])));
+    std::set<moleculeId_t> excluded;
+    excluded.insert(moleculeIds[MOLECULE_COUNT/2]);
+    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds,excluded));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
+    CPPUNIT_ASSERT_EQUAL( (size_t)(MOLECULE_COUNT-1), testMolecules.size());
+  }
+
+  {
+    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()||(MoleculeById(moleculeIds[MOLECULE_COUNT/2])));
+    CPPUNIT_ASSERT_EQUAL( (size_t)1, testMolecules.size());
+    CPPUNIT_ASSERT_EQUAL( moleculeIds[MOLECULE_COUNT/2], testMolecules[0]->getId());
+  }
+}
Index: src/unittests/MoleculeDescriptorTest.hpp
===================================================================
--- src/unittests/MoleculeDescriptorTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/MoleculeDescriptorTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,40 @@
+/*
+ * MoleculeDescriptorTest.hpp
+ *
+ *  Created on: Mar 4, 2010
+ *      Author: crueger
+ */
+
+#ifndef MOLECULEDESCRIPTORTEST_HPP_
+#define MOLECULEDESCRIPTORTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "types.hpp"
+
+#define MOLECULE_COUNT (10)
+
+class molecule;
+
+class MoleculeDescriptorTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( MoleculeDescriptorTest );
+  CPPUNIT_TEST ( MoleculeBaseSetsTest );
+  CPPUNIT_TEST ( MoleculeIdTest );
+  CPPUNIT_TEST ( MoleculeCalcTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void MoleculeBaseSetsTest();
+  void MoleculeIdTest();
+  void MoleculeCalcTest();
+
+private:
+  molecule *molecules [MOLECULE_COUNT];
+  moleculeId_t moleculeIds [MOLECULE_COUNT];
+};
+
+#endif /* MOLECULEDESCRIPTORTEST_HPP_ */
Index: src/unittests/ObserverTest.cpp
===================================================================
--- src/unittests/ObserverTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/ObserverTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,302 @@
+/*
+ * ObserverTest.cpp
+ *
+ *  Created on: Jan 19, 2010
+ *      Author: crueger
+ */
+
+#include "ObserverTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "Patterns/Observer.hpp"
+#include "Helpers/Assert.hpp"
+
+#include <iostream>
+
+using namespace std;
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ObserverTest );
+
+/******************* Test stubs ************************/
+
+class UpdateCountObserver : public Observer {
+public:
+  UpdateCountObserver() :
+    updates(0)
+  {};
+  void update(Observable *publisher){
+    updates++;
+  }
+  void subjectKilled(Observable *publisher) {
+  }
+  int updates;
+};
+
+class SimpleObservable : public Observable {
+public:
+  void changeMethod() {
+    OBSERVE;
+    int i = 0;
+    i++;
+  }
+};
+
+class CallObservable : public Observable {
+public:
+  void changeMethod1() {
+    OBSERVE;
+    int i = 0;
+    i++;
+  }
+
+  void changeMethod2() {
+    OBSERVE;
+    int i = 0;
+    i++;
+    changeMethod1();
+  }
+};
+
+class BlockObservable : public Observable {
+public:
+  void changeMethod1(){
+    OBSERVE;
+    // test if we report correctly as blocked
+    CPPUNIT_ASSERT(isBlocked());
+  }
+
+  void changeMethod2(){
+    OBSERVE;
+    internalMethod1();
+    internalMethod2();
+  }
+
+  void internalMethod1(){
+    // we did not block, but our caller did...
+    // see if this is found
+    CPPUNIT_ASSERT(isBlocked());
+  }
+
+  void internalMethod2(){
+    OBSERVE;
+    // Both this method and the caller do block
+    // Does the reporting still work as expected?
+    CPPUNIT_ASSERT(isBlocked());
+  }
+
+  void noChangeMethod(){
+    // No Block introduced here
+    // reported correctely?
+    CPPUNIT_ASSERT(!isBlocked());
+  }
+};
+
+class SuperObservable : public Observable {
+public:
+  SuperObservable(){
+    subObservable = new SimpleObservable();
+    subObservable->signOn(this);
+  }
+  ~SuperObservable(){
+    delete subObservable;
+  }
+  void changeMethod() {
+    OBSERVE;
+    int i = 0;
+    i++;
+    subObservable->changeMethod();
+  }
+  SimpleObservable *subObservable;
+};
+
+class NotificationObservable : public Observable {
+public:
+  NotificationObservable() :
+      notification1(new Notification(this)),
+      notification2(new Notification(this))
+  {}
+
+  ~NotificationObservable(){
+    delete notification1;
+    delete notification2;
+  }
+
+  void operation1(){
+    OBSERVE;
+    NOTIFY(notification1);
+  }
+
+  void operation2(){
+    OBSERVE;
+    NOTIFY(notification2);
+  }
+
+  Notification_ptr notification1;
+  Notification_ptr notification2;
+};
+
+class NotificationObserver : public Observer {
+public:
+  NotificationObserver(Notification_ptr notification) :
+    requestedNotification(notification),
+    wasNotified(false)
+  {}
+
+  void update(Observable*){}
+  void subjectKilled(Observable*){}
+  void recieveNotification(Observable *publisher, Notification_ptr notification){
+    ASSERT(requestedNotification==notification,"Notification received that was not requested");
+    wasNotified = true;
+  }
+
+  Notification_ptr requestedNotification;
+
+  bool wasNotified;
+};
+
+/******************* actuall tests ***************/
+
+void ObserverTest::setUp() {
+  ASSERT_DO(Assert::Throw);
+  simpleObservable1 = new SimpleObservable();
+  simpleObservable2 = new SimpleObservable();
+  callObservable = new CallObservable();
+  superObservable = new SuperObservable();
+  blockObservable = new BlockObservable();
+  notificationObservable = new NotificationObservable();
+
+  observer1 = new UpdateCountObserver();
+  observer2 = new UpdateCountObserver();
+  observer3 = new UpdateCountObserver();
+  observer4 = new UpdateCountObserver();
+
+  notificationObserver1 = new NotificationObserver(notificationObservable->notification1);
+  notificationObserver2 = new NotificationObserver(notificationObservable->notification2);
+
+}
+
+void ObserverTest::tearDown() {
+  delete simpleObservable1;
+  delete simpleObservable2;
+  delete callObservable;
+  delete superObservable;
+  delete blockObservable;
+  delete notificationObservable;
+
+  delete observer1;
+  delete observer2;
+  delete observer3;
+  delete observer4;
+  delete notificationObserver1;
+  delete notificationObserver2;
+}
+
+void ObserverTest::doesUpdateTest()
+{
+  simpleObservable1->signOn(observer1);
+  simpleObservable1->signOn(observer2);
+  simpleObservable1->signOn(observer3);
+
+  simpleObservable2->signOn(observer2);
+  simpleObservable2->signOn(observer4);
+
+  simpleObservable1->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer2->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer3->updates );
+  CPPUNIT_ASSERT_EQUAL( 0, observer4->updates );
+
+  simpleObservable1->signOff(observer3);
+
+  simpleObservable1->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 2, observer2->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer3->updates );
+  CPPUNIT_ASSERT_EQUAL( 0, observer4->updates );
+
+  simpleObservable2->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 3, observer2->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer3->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer4->updates );
+}
+
+
+void ObserverTest::doesBlockUpdateTest() {
+  callObservable->signOn(observer1);
+
+  callObservable->changeMethod1();
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
+
+  callObservable->changeMethod2();
+  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
+}
+
+void ObserverTest::doesSubObservableTest() {
+  superObservable->signOn(observer1);
+  superObservable->subObservable->signOn(observer2);
+
+  superObservable->subObservable->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 1, observer2->updates );
+
+  superObservable->changeMethod();
+  CPPUNIT_ASSERT_EQUAL( 2, observer1->updates );
+  CPPUNIT_ASSERT_EQUAL( 2, observer2->updates );
+}
+
+void ObserverTest::doesNotifyTest(){
+  notificationObservable->signOn(notificationObserver1,
+                                 notificationObservable->notification1);
+  notificationObservable->signOn(notificationObserver2,
+                                 notificationObservable->notification2);
+
+  notificationObservable->operation1();
+  CPPUNIT_ASSERT(notificationObserver1->wasNotified);
+  CPPUNIT_ASSERT(!notificationObserver2->wasNotified);
+
+  notificationObserver1->wasNotified=false;
+
+  notificationObservable->operation2();
+  CPPUNIT_ASSERT(!notificationObserver1->wasNotified);
+  CPPUNIT_ASSERT(notificationObserver2->wasNotified);
+
+}
+
+void ObserverTest::doesReportTest(){
+  // Actual checks are in the Stub-methods for this
+  blockObservable->changeMethod1();
+  blockObservable->changeMethod2();
+  blockObservable->noChangeMethod();
+}
+
+void ObserverTest::CircleDetectionTest() {
+  cout << endl << "Warning: the next test involved methods that can produce infinite loops." << endl;
+  cout << "Errors in this methods can not be checked using the CPPUNIT_ASSERT Macros." << endl;
+  cout << "Instead tests are run on these methods to see if termination is assured" << endl << endl;
+  cout << "If this test does not complete in a few seconds, kill the test-suite and fix the Error in the circle detection mechanism" << endl;
+
+  cout << endl << endl << "The following errors displayed by the observer framework can be ignored" << endl;
+
+  // make this Observable its own subject. NEVER DO THIS IN ACTUAL CODE
+  simpleObservable1->signOn(simpleObservable1);
+  CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure);
+
+  // more complex test
+  simpleObservable1->signOff(simpleObservable1);
+  simpleObservable1->signOn(simpleObservable2);
+  simpleObservable2->signOn(simpleObservable1);
+  CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure);
+  simpleObservable1->signOff(simpleObservable2);
+  simpleObservable2->signOff(simpleObservable1);
+  // when we reach this line, although we broke the DAG assumption the circle check works fine
+  CPPUNIT_ASSERT(true);
+}
Index: src/unittests/ObserverTest.hpp
===================================================================
--- src/unittests/ObserverTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/ObserverTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,62 @@
+/*
+ * ObserverTest.hpp
+ *
+ *  Created on: Jan 19, 2010
+ *      Author: crueger
+ */
+
+#ifndef OBSERVERTEST_HPP_
+#define OBSERVERTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+// forward declaration for test stubs
+class UpdateCountObserver;
+class NotificationObserver;
+class SimpleObservable;
+class CallObservable;
+class SuperObservable;
+class BlockObservable;
+class NotificationObservable;
+
+
+class ObserverTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( ObserverTest ) ;
+  CPPUNIT_TEST ( doesUpdateTest );
+  CPPUNIT_TEST ( doesBlockUpdateTest );
+  CPPUNIT_TEST ( doesSubObservableTest );
+  CPPUNIT_TEST ( doesNotifyTest );
+  CPPUNIT_TEST ( doesReportTest );
+  CPPUNIT_TEST ( CircleDetectionTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void doesUpdateTest();
+  void doesBlockUpdateTest();
+  void doesSubObservableTest();
+  void doesNotifyTest();
+  void doesReportTest();
+  void CircleDetectionTest();
+
+private:
+  UpdateCountObserver *observer1;
+  UpdateCountObserver *observer2;
+  UpdateCountObserver *observer3;
+  UpdateCountObserver *observer4;
+
+  NotificationObserver *notificationObserver1;
+  NotificationObserver *notificationObserver2;
+
+  SimpleObservable *simpleObservable1;
+  SimpleObservable *simpleObservable2;
+  CallObservable *callObservable;
+  BlockObservable *blockObservable;
+  SuperObservable *superObservable;
+  NotificationObservable *notificationObservable;
+};
+
+#endif /* OBSERVERTEST_HPP_ */
Index: src/unittests/SingletonTest.cpp
===================================================================
--- src/unittests/SingletonTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/SingletonTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,143 @@
+/*
+ * SingletonTest.cpp
+ *
+ *  Created on: Mar 11, 2010
+ *      Author: crueger
+ */
+
+#include "SingletonTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+
+#include "Patterns/Singleton.hpp"
+#include "Patterns/Singleton_impl.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+CPPUNIT_TEST_SUITE_REGISTRATION( SingletonTest );
+
+// some necessary stubs
+class SingletonStub1 : public Singleton <SingletonStub1>{
+  friend class Singleton<SingletonStub1>;
+private:
+  SingletonStub1(){
+    count1++;
+  }
+  // explicit copy constructor to catch if this is ever called
+  SingletonStub1(const SingletonStub1&){
+    CPPUNIT_FAIL    ( "Copy constructor of Singleton called" );
+  }
+  virtual ~SingletonStub1(){
+    count2++;
+  }
+public:
+  static int count1;
+  static int count2;
+};
+
+int SingletonStub1::count1 = 0;
+int SingletonStub1::count2 = 0;
+
+CONSTRUCT_SINGLETON(SingletonStub1);
+
+class SingletonStub2 : public Singleton<SingletonStub2>{
+  friend class Singleton<SingletonStub2>;
+private:
+  SingletonStub2(){
+    count1++;
+  }
+  // explicit copy constructor to catch if thsi is ever called
+  SingletonStub2(const SingletonStub2&){
+    CPPUNIT_FAIL    ( "Copy constructor of Singleton called" );
+  }
+  virtual ~SingletonStub2(){
+    count2++;
+  }
+public:
+  static int count1;
+  static int count2;
+};
+
+int SingletonStub2::count1 = 0;
+int SingletonStub2::count2 = 0;
+
+CONSTRUCT_SINGLETON(SingletonStub2);
+
+void SingletonTest::setUp(){}
+void SingletonTest::tearDown(){}
+
+void SingletonTest::ConstructionTest(){
+  void *ptr_1_1 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+  void *ptr_1_2 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+  void *ptr_1_3 = reinterpret_cast<void*>(&(SingletonStub1::getInstance()));
+
+  // test if we always get the same instance of our singleton
+  CPPUNIT_ASSERT_EQUAL(ptr_1_1,ptr_1_2);
+  CPPUNIT_ASSERT_EQUAL(ptr_1_1,ptr_1_3);
+
+  void *ptr_2_1 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+  void *ptr_2_2 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+  void *ptr_2_3 = reinterpret_cast<void*>(&(SingletonStub2::getInstance()));
+
+  // same as above but for a different singleton
+  CPPUNIT_ASSERT_EQUAL(ptr_2_1,ptr_2_2);
+  CPPUNIT_ASSERT_EQUAL(ptr_2_1,ptr_2_3);
+
+  // see if the two singletons actually differ
+  CPPUNIT_ASSERT(ptr_1_1!=ptr_2_1);
+
+  // see if each constructor was called exactly once
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub1::count1);
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub2::count1);
+  // no calls to the destructor should have occured so far
+  CPPUNIT_ASSERT_EQUAL(0,SingletonStub1::count2);
+  CPPUNIT_ASSERT_EQUAL(0,SingletonStub2::count2);
+
+  SingletonStub1::purgeInstance();
+
+  void *ptr_3_1 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+  void *ptr_3_2 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+
+  // now the constructor should have been called twice
+  CPPUNIT_ASSERT_EQUAL(2,SingletonStub1::count1);
+  // the destructor should have been called once
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub1::count2);
+  // see if the singleton Assumption holds
+  CPPUNIT_ASSERT_EQUAL(ptr_3_1,ptr_3_2);
+  // Some esoteric thing might cause our pointer to lay at the position of Singleton2 now
+  // See that those two objects still differ
+  CPPUNIT_ASSERT(ptr_3_1!=ptr_2_1);
+  // don't test for pointer difference between first and second singleton here,
+  // because they might be constructed in the same place
+
+
+  SingletonStub2::resetInstance();
+  // now the constructor should have been called twice
+  CPPUNIT_ASSERT_EQUAL(2,SingletonStub2::count1);
+  // the destructor should have been called once
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub2::count2);
+
+  void *ptr_4_1 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+  void *ptr_4_2 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+
+  // Still only two calls to the constructor, one call to destructor
+  CPPUNIT_ASSERT_EQUAL(2,SingletonStub2::count1);
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub2::count2);
+
+  // test if Singleton assumption can be broken by reset
+  CPPUNIT_ASSERT_EQUAL(ptr_4_1,ptr_4_2);
+
+  // and again test if we actually have a object seperate from anything else
+  CPPUNIT_ASSERT(ptr_4_1!=ptr_3_1);
+
+
+  // we don't purge our singletons here. Purging should be done automatically by the Singleton
+  // mechanism. Check with Valgrind to see if memory-leak occurs
+  std::cout << "Not purging Singleton!\n Check with Valgrind to see if automatic purgins is working!" << std::endl;
+
+}
Index: src/unittests/SingletonTest.hpp
===================================================================
--- src/unittests/SingletonTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/SingletonTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,26 @@
+/*
+ * SingletonTest.hpp
+ *
+ *  Created on: Mar 11, 2010
+ *      Author: crueger
+ */
+
+#ifndef SINGLETONTEST_HPP_
+#define SINGLETONTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class SingletonTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( SingletonTest );
+  CPPUNIT_TEST ( ConstructionTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void ConstructionTest();
+};
+
+#endif /* SINGLETONTEST_HPP_ */
Index: src/unittests/TestRunnerMain.cpp
===================================================================
--- src/unittests/TestRunnerMain.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/TestRunnerMain.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,13 @@
+/*
+ * TestRunnerMain.cpp
+ *
+ *  Created on: Feb 25, 2010
+ *      Author: heber
+ */
+
+// give the main function its correct name
+#define CPPUNIT_MAIN main
+
+// include the TestRunnerClient file containing the main class
+#include "../../../TestRunnerClient.h"
+#include "../../../TestRunnerClient.cpp"
Index: src/unittests/UnitTestMain.cpp
===================================================================
--- src/unittests/UnitTestMain.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/UnitTestMain.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,36 @@
+/*
+ * UnitTestMain.cpp
+ *
+ *  Created on: Feb 24, 2010
+ *      Author: heber
+ */
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/********************************************** 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/analysisbondsunittest.cpp
===================================================================
--- src/unittests/analysisbondsunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/analysisbondsunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -16,4 +16,5 @@
 #include <cstring>
 
+#include "World.hpp"
 #include "analysis_bonds.hpp"
 #include "analysisbondsunittest.hpp"
@@ -24,4 +25,8 @@
 #include "molecule.hpp"
 #include "periodentafel.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -56,27 +61,27 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::getInstance().getPeriode();
   tafel->AddElement(hydrogen);
   tafel->AddElement(carbon);
 
   // construct molecule (tetraeder of hydrogens)
-  TestMolecule = new molecule(tafel);
-  Walker = new atom();
+  TestMolecule = World::getInstance().createMolecule();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(1.5, 0., 1.5 );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(0., 1.5, 1.5 );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(1.5, 1.5, 0. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(0., 0., 0. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = carbon;
   Walker->node->Init(0.5, 0.5, 0.5 );
@@ -112,8 +117,7 @@
 
   // remove molecule
-  delete(TestMolecule);
+  World::getInstance().destroyMolecule(TestMolecule);
   // note that all the atoms are cleaned by TestMolecule
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::purgeInstance();
 };
 
@@ -163,24 +167,2 @@
   CPPUNIT_ASSERT_EQUAL( 0. , Max );
 };
-
-
-/********************************************** 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/atomsCalculationTest.cpp
===================================================================
--- src/unittests/atomsCalculationTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/atomsCalculationTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,93 @@
+/*
+ * atomsCalculationTest.cpp
+ *
+ *  Created on: Feb 19, 2010
+ *      Author: crueger
+ */
+
+#include "atomsCalculationTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+#include <boost/bind.hpp>
+
+#include "Descriptors/AtomDescriptor.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Actions/AtomsCalculation.hpp"
+#include "Actions/AtomsCalculation_impl.hpp"
+#include "Actions/ActionRegistry.hpp"
+
+#include "World.hpp"
+#include "World_calculations.hpp"
+#include "atom.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( atomsCalculationTest );
+
+// set up and tear down
+void atomsCalculationTest::setUp(){
+  World::getInstance();
+  for(int i=0;i<ATOM_COUNT;++i){
+    atoms[i]= World::getInstance().createAtom();
+    atomIds[i]= atoms[i]->getId();
+  }
+}
+void atomsCalculationTest::tearDown(){
+  World::purgeInstance();
+  ActionRegistry::purgeInstance();
+}
+
+// some helper functions
+static bool hasAllIds(std::vector<atomId_t> atoms,atomId_t ids[ATOM_COUNT], std::set<atomId_t> excluded = std::set<atomId_t>()){
+  for(int i=0;i<ATOM_COUNT;++i){
+    atomId_t id = ids[i];
+    if(!excluded.count(id)){
+      std::vector<atomId_t>::iterator iter;
+      bool res=false;
+      for(iter=atoms.begin();iter!=atoms.end();++iter){
+        res |= (*iter) == id;
+      }
+      if(!res) {
+        cout << "Atom " << id << " missing in returned list" << endl;
+        return false;
+      }
+    }
+  }
+  return true;
+}
+
+static bool hasNoDuplicates(std::vector<atomId_t> ids){
+  std::set<atomId_t> found;
+  std::vector<atomId_t>::iterator iter;
+  for(iter=ids.begin();iter!=ids.end();++iter){
+    int id = (*iter);
+    if(found.count(id))
+      return false;
+    found.insert(id);
+  }
+  return true;
+}
+
+void atomsCalculationTest::testCalculateSimple(){
+  AtomsCalculation<atomId_t> *calc = World::getInstance().calcOnAtoms<atomId_t>(boost::bind(&atom::getId,_1),"FOO",AllAtoms());
+  std::vector<atomId_t> allIds = (*calc)();
+  CPPUNIT_ASSERT(hasAllIds(allIds,atomIds));
+  CPPUNIT_ASSERT(hasNoDuplicates(allIds));
+}
+
+void atomsCalculationTest::testCalculateExcluded(){
+  atomId_t excluded = atomIds[ATOM_COUNT/2];
+  AtomsCalculation<atomId_t> *calc = World::getInstance().calcOnAtoms<atomId_t>(boost::bind(&atom::getId,_1),"FOO",AllAtoms() && !AtomById(excluded));
+  std::vector<atomId_t> allIds = (*calc)();
+  std::set<atomId_t> excluded_set;
+  excluded_set.insert(excluded);
+  CPPUNIT_ASSERT(hasAllIds(allIds,atomIds,excluded_set));
+  CPPUNIT_ASSERT(hasNoDuplicates(allIds));
+  CPPUNIT_ASSERT_EQUAL((size_t)(ATOM_COUNT-1),allIds.size());
+}
Index: src/unittests/atomsCalculationTest.hpp
===================================================================
--- src/unittests/atomsCalculationTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/atomsCalculationTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,38 @@
+/*
+ * atomsCalculationTest.hpp
+ *
+ *  Created on: Feb 19, 2010
+ *      Author: crueger
+ */
+
+#ifndef ATOMSCALCULATIONTEST_HPP_
+#define ATOMSCALCULATIONTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#define ATOM_COUNT (10)
+
+#include "types.hpp"
+
+class atom;
+
+class atomsCalculationTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( atomsCalculationTest );
+  CPPUNIT_TEST ( testCalculateSimple );
+  CPPUNIT_TEST ( testCalculateExcluded );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void testCalculateSimple();
+  void testCalculateExcluded();
+
+private:
+  atom *atoms [ATOM_COUNT];
+  atomId_t atomIds [ATOM_COUNT];
+};
+
+#endif /* ATOMSCALCULATIONTEST_HPP_ */
Index: src/unittests/bondgraphunittest.cpp
===================================================================
--- src/unittests/bondgraphunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/bondgraphunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -16,4 +16,5 @@
 #include <cstring>
 
+#include "World.hpp"
 #include "atom.hpp"
 #include "bond.hpp"
@@ -24,4 +25,9 @@
 #include "periodentafel.hpp"
 #include "bondgraphunittest.hpp"
+#include "World.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -56,23 +62,23 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::getInstance().getPeriode();
   tafel->AddElement(hydrogen);
   tafel->AddElement(carbon);
 
   // construct molecule (tetraeder of hydrogens)
-  TestMolecule = new molecule(tafel);
-  Walker = new atom();
+  TestMolecule = World::getInstance().createMolecule();
+  Walker = World::getInstance().createAtom();
   Walker->type = carbon;
   Walker->node->Init(1., 0., 1. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = carbon;
   Walker->node->Init(0., 1., 1. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = carbon;
   Walker->node->Init(1., 1., 0. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = carbon;
   Walker->node->Init(0., 0., 0. );
@@ -103,8 +109,10 @@
 
   // remove molecule
-  delete(TestMolecule);
-  // note that all the atoms are cleaned by TestMolecule
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::getInstance().destroyMolecule(TestMolecule);
+  // note that all the atoms, molecules, the tafel and the elements
+  // are all cleaned when the world is destroyed
+  World::purgeInstance();
+  MemoryUsageObserver::purgeInstance();
+  logger::purgeInstance();
 };
 
@@ -143,23 +151,2 @@
 };
 
-
-/********************************************** 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.cpp
===================================================================
--- src/unittests/gslmatrixsymmetricunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/gslmatrixsymmetricunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -13,4 +13,8 @@
 
 #include "gslmatrixsymmetricunittest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -266,23 +270,2 @@
   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/gslmatrixunittest.cpp
===================================================================
--- src/unittests/gslmatrixunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/gslmatrixunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -13,4 +13,8 @@
 
 #include "gslmatrixunittest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -248,23 +252,2 @@
   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/gslvectorunittest.cpp
===================================================================
--- src/unittests/gslvectorunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/gslvectorunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -13,4 +13,8 @@
 
 #include "gslvectorunittest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -114,5 +118,4 @@
 };
 
-
 /** UnitTest for operators.
  */
@@ -160,23 +163,2 @@
   CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() );
 };
-
-/********************************************** 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/infounittest.cpp
===================================================================
--- src/unittests/infounittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/infounittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -17,4 +17,9 @@
 #include "info.hpp"
 #include "infounittest.hpp"
+#include "log.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -31,4 +36,5 @@
 void InfoTest::tearDown()
 {
+  logger::purgeInstance();
 };
 
@@ -43,24 +49,2 @@
   CPPUNIT_ASSERT_EQUAL( 1, test.verbosity );
 };
-
-
-/********************************************** 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.cpp
===================================================================
--- src/unittests/linearsystemofequationsunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/linearsystemofequationsunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -15,4 +15,8 @@
 #include "linearsystemofequationsunittest.hpp"
 #include "vector.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -103,23 +107,2 @@
   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/listofbondsunittest.cpp
===================================================================
--- src/unittests/listofbondsunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/listofbondsunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -16,4 +16,5 @@
 #include "listofbondsunittest.hpp"
 
+#include "World.hpp"
 #include "atom.hpp"
 #include "bond.hpp"
@@ -21,4 +22,9 @@
 #include "molecule.hpp"
 #include "periodentafel.hpp"
+#include "World.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -45,22 +51,22 @@
 
   // construct periodentafel
-  tafel = new periodentafel;
+  tafel = World::getInstance().getPeriode();
   tafel->AddElement(hydrogen);
 
   // construct molecule (tetraeder of hydrogens)
-  TestMolecule = new molecule(tafel);
-  Walker = new atom();
+  TestMolecule = World::getInstance().createMolecule();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(1., 0., 1. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(0., 1., 1. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(1., 1., 0. );
   TestMolecule->AddAtom(Walker);
-  Walker = new atom();
+  Walker = World::getInstance().createAtom();
   Walker->type = hydrogen;
   Walker->node->Init(0., 0., 0. );
@@ -76,8 +82,10 @@
 {
   // remove
-  delete(TestMolecule);
-  // note that all the atoms are cleaned by TestMolecule
-  delete(tafel);
-  // note that element is cleaned by periodentafel
+  World::getInstance().destroyMolecule(TestMolecule);
+  // note that all the atoms, molecules, the tafel and the elements
+  // are all cleaned when the world is destroyed
+  World::purgeInstance();
+  MemoryUsageObserver::purgeInstance();
+  logger::purgeInstance();
 };
 
@@ -242,5 +250,5 @@
 
   // remove atom2
-  delete(atom2);
+  World::getInstance().destroyAtom(atom2);
 
   // check bond if removed from other atom
@@ -250,23 +258,2 @@
   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
 };
-
-/********************************************** 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/logunittest.cpp
===================================================================
--- src/unittests/logunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/logunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -15,4 +15,8 @@
 #include "verbose.hpp"
 
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
 /********************************************** Test classes **************************************/
 
@@ -27,4 +31,6 @@
 void LogTest::tearDown()
 {
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
 };
 
@@ -34,5 +40,5 @@
 void LogTest::logTest()
 {
-  logger::getInstance()->setVerbosity(2);
+  logger::getInstance().setVerbosity(2);
   DoLog(0) && (Log() << Verbose(0) << "Verbosity level is set to 2." << endl);
   DoLog(0) && (Log() << Verbose(0) << "Test level 0" << endl);
@@ -48,24 +54,2 @@
   DoeLog(4) && (eLog()<< Verbose(4) << "This should not be printed." << endl);
 };
-
-
-/********************************************** 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/manipulateAtomsTest.cpp
===================================================================
--- src/unittests/manipulateAtomsTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/manipulateAtomsTest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,132 @@
+/*
+ * manipulateAtomsTest.cpp
+ *
+ *  Created on: Feb 18, 2010
+ *      Author: crueger
+ */
+
+#include "manipulateAtomsTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+#include <boost/bind.hpp>
+
+#include "Descriptors/AtomDescriptor.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Actions/ManipulateAtomsProcess.hpp"
+#include "Actions/ActionRegistry.hpp"
+#include "Actions/ActionHistory.hpp"
+
+#include "World.hpp"
+#include "atom.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( manipulateAtomsTest );
+
+// some stubs
+class AtomStub : public atom {
+public:
+  AtomStub(int _id) :
+  atom(),
+  manipulated(false),
+  id(_id)
+  {}
+
+  virtual atomId_t getId(){
+    return id;
+  }
+
+  virtual void doSomething(){
+    manipulated = true;
+  }
+
+  bool manipulated;
+private:
+  atomId_t id;
+};
+
+class countObserver : public Observer{
+public:
+  countObserver() :
+    count(0)
+    {}
+  virtual ~countObserver(){}
+
+  void update(Observable *){
+    count++;
+  }
+
+  void subjectKilled(Observable *)
+  {}
+
+  int count;
+};
+
+// set up and tear down
+void manipulateAtomsTest::setUp(){
+  ActionHistory::init();
+  World::getInstance();
+  for(int i=0;i<ATOM_COUNT;++i){
+    atoms[i]= new AtomStub(i);
+    World::getInstance().registerAtom(atoms[i]);
+  }
+}
+void manipulateAtomsTest::tearDown(){
+  World::purgeInstance();
+  ActionRegistry::purgeInstance();
+  ActionHistory::purgeInstance();
+}
+
+static void operation(atom* _atom){
+  AtomStub *atom = dynamic_cast<AtomStub*>(_atom);
+  assert(atom);
+  atom->doSomething();
+}
+
+
+void manipulateAtomsTest::testManipulateSimple(){
+  ManipulateAtomsProcess *proc = World::getInstance().manipulateAtoms(boost::bind(operation,_1),"FOO",AllAtoms());
+  proc->call();
+  std::vector<atom*> allAtoms = World::getInstance().getAllAtoms(AllAtoms());
+  std::vector<atom*>::iterator iter;
+  for(iter=allAtoms.begin();iter!=allAtoms.end();++iter){
+    AtomStub *atom;
+    atom = dynamic_cast<AtomStub*>(*iter);
+    assert(atom);
+    CPPUNIT_ASSERT(atom->manipulated);
+  }
+}
+
+void manipulateAtomsTest::testManipulateExcluded(){
+
+  ManipulateAtomsProcess *proc = World::getInstance().manipulateAtoms(boost::bind(operation,_1),"FOO",AllAtoms() && !AtomById(ATOM_COUNT/2));
+  proc->call();
+  std::vector<atom*> allAtoms = World::getInstance().getAllAtoms(AllAtoms());
+  std::vector<atom*>::iterator iter;
+  for(iter=allAtoms.begin();iter!=allAtoms.end();++iter){
+    AtomStub *atom;
+    atom = dynamic_cast<AtomStub*>(*iter);
+    assert(atom);
+    if(atom->getId()!=(int)ATOM_COUNT/2)
+      CPPUNIT_ASSERT(atom->manipulated);
+    else
+      CPPUNIT_ASSERT(!atom->manipulated);
+  }
+}
+
+void manipulateAtomsTest::testObserver(){
+  countObserver *obs = new countObserver();
+  World::getInstance().signOn(obs);
+  ManipulateAtomsProcess *proc = World::getInstance().manipulateAtoms(boost::bind(operation,_1),"FOO",AllAtoms());
+  proc->call();
+
+  CPPUNIT_ASSERT_EQUAL(1,obs->count);
+  World::getInstance().signOff(obs);
+  delete obs;
+}
Index: src/unittests/manipulateAtomsTest.hpp
===================================================================
--- src/unittests/manipulateAtomsTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/unittests/manipulateAtomsTest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -0,0 +1,37 @@
+/*
+ * manipulateAtomsTest.hpp
+ *
+ *  Created on: Feb 18, 2010
+ *      Author: crueger
+ */
+
+#ifndef MANIPULATEATOMSTEST_HPP_
+#define MANIPULATEATOMSTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#define ATOM_COUNT (10)
+
+class atom;
+
+class manipulateAtomsTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( manipulateAtomsTest );
+  CPPUNIT_TEST ( testManipulateSimple );
+  CPPUNIT_TEST ( testManipulateExcluded );
+  CPPUNIT_TEST ( testObserver );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void testManipulateSimple();
+  void testManipulateExcluded();
+  void testObserver();
+
+private:
+  atom *atoms [ATOM_COUNT];
+};
+
+#endif /* MANIPULATEATOMSTEST_HPP_ */
Index: src/unittests/memoryallocatorunittest.cpp
===================================================================
--- src/unittests/memoryallocatorunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/memoryallocatorunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -13,5 +13,10 @@
 #include "memoryallocatorunittest.hpp"
 #include "helpers.hpp"
+#include "log.hpp"
 #include "defs.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -29,4 +34,5 @@
 {
   MemoryUsageObserver::getInstance()->purgeInstance();
+  logger::purgeInstance();
 };
 
@@ -102,24 +108,2 @@
   Free(buffer2);
 };
-
-
-/********************************************** 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/memoryusageobserverunittest.cpp
===================================================================
--- src/unittests/memoryusageobserverunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/memoryusageobserverunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -14,4 +14,8 @@
 #include "memoryusageobserverunittest.hpp"
 
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
 /********************************************** Test classes **************************************/
 // Registers the fixture into the 'registry'
@@ -27,4 +31,6 @@
 {
   MemoryUsageObserver::purgeInstance();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
 };
 
@@ -70,4 +76,5 @@
   MemoryUsageObserver::getInstance()->removeMemory(i);
   CPPUNIT_ASSERT_EQUAL((size_t) 0, MemoryUsageObserver::getInstance()->getUsedMemorySize());
+  Free(i);
 };
 
@@ -80,4 +87,5 @@
   MemoryUsageObserver::getInstance()->removeMemory(i);
   CPPUNIT_ASSERT_EQUAL((size_t) 0, MemoryUsageObserver::getInstance()->getUsedMemorySize());
+  Free(i);
 };
 
@@ -92,4 +100,6 @@
   MemoryUsageObserver::getInstance()->addMemory(j, sizeof(int));
   CPPUNIT_ASSERT_EQUAL(2 * sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
+  Free(i);
+  Free(j);
 };
 
@@ -103,4 +113,5 @@
   MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
   CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getUsedMemorySize());
+  Free(i);
 };
 
@@ -114,4 +125,5 @@
   MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
   CPPUNIT_ASSERT_EQUAL(2 * sizeof(int), MemoryUsageObserver::getInstance()->getMaximumUsedMemory());
+  Free(i);
 };
 
@@ -125,4 +137,5 @@
   MemoryUsageObserver::getInstance()->removeMemory(i);
   CPPUNIT_ASSERT_EQUAL(sizeof(int), MemoryUsageObserver::getInstance()->getMaximumUsedMemory());
+  Free(i);
 };
 
@@ -135,25 +148,4 @@
   MemoryUsageObserver::getInstance()->addMemory(i, sizeof(int));
   CPPUNIT_ASSERT_EQUAL(i, (int*) MemoryUsageObserver::getInstance()->getPointersToAllocatedMemory().begin()->first);
+  Free(i);
 };
-
-
-/********************************************** 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/stackclassunittest.cpp
===================================================================
--- src/unittests/stackclassunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/stackclassunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -14,4 +14,8 @@
 #include "stackclassunittest.hpp"
 #include "log.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 enum { testdimension=3 };
@@ -33,4 +37,6 @@
   Stack->ClearStack();
   delete(Stack);
+  MemoryUsageObserver::purgeInstance();
+  logger::purgeInstance();
 };
 
@@ -67,24 +73,2 @@
   CPPUNIT_ASSERT_EQUAL(0, Stack->ItemCount());
 };
-
-
-/********************************************** 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.cpp
===================================================================
--- src/unittests/tesselation_boundarytriangleunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/tesselation_boundarytriangleunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -18,4 +18,8 @@
 #include "tesselation_boundarytriangleunittest.hpp"
 
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
 #define SPHERERADIUS 2.
 
@@ -31,23 +35,22 @@
 
   // 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);
+  tesselpoints[0] = new TesselPoint;
+  tesselpoints[0]->node = new Vector(0., 0., 0.);
+  tesselpoints[0]->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name");
+  strcpy(tesselpoints[0]->Name, "1");
+  tesselpoints[0]->nr = 1;
+  points[0] = new BoundaryPointSet(tesselpoints[0]);
+  tesselpoints[1] = new TesselPoint;
+  tesselpoints[1]->node = new Vector(0., 1., 0.);
+  tesselpoints[1]->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name");
+  strcpy(tesselpoints[1]->Name, "2");
+  tesselpoints[1]->nr = 2;
+  points[1] = new BoundaryPointSet(tesselpoints[1]);
+  tesselpoints[2] = new TesselPoint;
+  tesselpoints[2] ->node = new Vector(1., 0., 0.);
+  tesselpoints[2] ->Name = Malloc<char>(3, "TesselationBoundaryTriangleTest::setUp - *Name");
+  strcpy(tesselpoints[2] ->Name, "3");
+  tesselpoints[2] ->nr = 3;
+  points[2] = new BoundaryPointSet(tesselpoints[2] );
 
   // create line
@@ -65,4 +68,9 @@
 {
   delete(triangle);
+  for (int i=0;i<3;++i) {
+    // TesselPoint does not delete its vector as it only got a reference
+    delete tesselpoints[i]->node;
+    delete tesselpoints[i];
+  }
   MemoryUsageObserver::purgeInstance();
   logger::purgeInstance();
@@ -191,24 +199,2 @@
   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 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/tesselation_boundarytriangleunittest.hpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -35,4 +35,5 @@
       class BoundaryLineSet *lines[3];
       class BoundaryPointSet *points[3];
+      class TesselPoint *tesselpoints[3];
       LinkedCell::LinkedNodes Corners;
 };
Index: src/unittests/tesselation_insideoutsideunittest.cpp
===================================================================
--- src/unittests/tesselation_insideoutsideunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/tesselation_insideoutsideunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -17,4 +17,8 @@
 #include "tesselation.hpp"
 #include "tesselation_insideoutsideunittest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 #define SPHERERADIUS 2.
@@ -161,23 +165,2 @@
       }
 };
-
-/********************************************** 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/tesselationunittest.cpp
===================================================================
--- src/unittests/tesselationunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/tesselationunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -18,4 +18,8 @@
 #include "tesselation.hpp"
 #include "tesselationunittest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 #define SPHERERADIUS 2.
@@ -177,23 +181,2 @@
   }
 }
-
-/********************************************** 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/vectorunittest.cpp
===================================================================
--- src/unittests/vectorunittest.cpp	(revision 6cd16bc4b2635b48c1eb855a13b887a00af82259)
+++ src/unittests/vectorunittest.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
@@ -14,6 +14,12 @@
 
 #include "defs.hpp"
+#include "log.hpp"
+#include "memoryusageobserver.hpp"
 #include "vector.hpp"
 #include "vectorunittest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
 
 /********************************************** Test classes **************************************/
@@ -35,4 +41,7 @@
 void VectorTest::tearDown()
 {
+  MemoryUsageObserver::purgeInstance();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
 };
 
@@ -290,23 +299,2 @@
 }
 
-
-/********************************************** 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;
-};
