diff --git a/BaseLib/Configure.h.in b/BaseLib/Configure.h.in
index c2afaf7e62f20838c60d43e574ce2aa90287073d..42b11b471546c39b3d6088f8954f9a9afa93c30e 100644
--- a/BaseLib/Configure.h.in
+++ b/BaseLib/Configure.h.in
@@ -35,6 +35,7 @@
 #cmakedefine HAVE_SYS_TYPES_H 1
 #cmakedefine HAVE_UNISTD_H 1
 #cmakedefine HAVE_SYS_MOUNT_H 1
+#cmakedefine QT4_FOUND ${QT4_FOUND}
 
 #define SOURCEPATH "${CMAKE_SOURCE_DIR}"
 
diff --git a/GeoLib/Polyline.cpp b/GeoLib/Polyline.cpp
index 302814e7574e7735824abec4c70f5404c6035eab..e29645b437c000aa79d470f46ca26a8b6b9d16ba 100644
--- a/GeoLib/Polyline.cpp
+++ b/GeoLib/Polyline.cpp
@@ -84,12 +84,19 @@ void Polyline::insertPoint(std::size_t pos, std::size_t pnt_id)
 	}
 
 	// check if inserting pnt_id would result in two identical IDs for adjacent points
-	if (pos == 0 && pnt_id == _ply_pnt_ids[0])
-		return;
-	else if (pos == (_ply_pnt_ids.size() - 1) && pnt_id == _ply_pnt_ids[pos])
-		return;
-	else if (pnt_id == _ply_pnt_ids[pos - 1] || pnt_id == _ply_pnt_ids[pos])
+	if (pos == 0 && pnt_id == _ply_pnt_ids[0]) {
 		return;
+	} else {
+		if (pos != 0) {
+			if (pos == (_ply_pnt_ids.size() - 1) && pnt_id == _ply_pnt_ids[pos]) {
+				return;
+			} else {
+				if (pnt_id == _ply_pnt_ids[pos - 1] || pnt_id == _ply_pnt_ids[pos]) {
+					return;
+				}
+			}
+		}
+	}
 
 	std::vector<std::size_t>::iterator it(_ply_pnt_ids.begin() + pos);
 	_ply_pnt_ids.insert(it, pnt_id);
diff --git a/Tests/BaseLib/TestQuicksort.cpp b/Tests/BaseLib/TestQuicksort.cpp
index 9daad2fce7df25549bac51b6c3ae45eceab0e379..cddce7a1d87d65df713ff8f5f40ed89888042e7a 100644
--- a/Tests/BaseLib/TestQuicksort.cpp
+++ b/Tests/BaseLib/TestQuicksort.cpp
@@ -28,7 +28,8 @@ class QuicksortSortsAsSTLSort : public Property<std::vector<int>> {
     bool holdsFor(const std::vector<int>& xs)
     {
         std::vector<size_t> perm(xs.size());
-        BaseLib::quicksort((int*)&(xs[0]), 0, xs.size(), &(perm[0]));
+        if (! xs.empty())
+        	BaseLib::quicksort((int*)&(xs[0]), 0, xs.size(), &(perm[0]));
         return std::is_sorted(xs.begin(), xs.end());
     }
 
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index dbf8bbea93b492a391138520b26776cfe37465af..d9245f5b849e0384c00db5570691030cfb1a1e0b 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -10,11 +10,18 @@ APPEND_SOURCE_FILES(TEST_SOURCES GeoLib)
 APPEND_SOURCE_FILES(TEST_SOURCES MathLib)
 APPEND_SOURCE_FILES(TEST_SOURCES MeshLib)
 
+IF (QT4_FOUND)
+	APPEND_SOURCE_FILES(TEST_SOURCES FileIO)
+ENDIF()
+
 INCLUDE_DIRECTORIES(
 	${CMAKE_SOURCE_DIR}/BaseLib
+	${CMAKE_SOURCE_DIR}/FemLib
+	${CMAKE_SOURCE_DIR}/FileIO
 	${CMAKE_SOURCE_DIR}/GeoLib
 	${CMAKE_SOURCE_DIR}/MathLib
 	${CMAKE_SOURCE_DIR}/MeshLib
+	${CMAKE_BINARY_DIR}/BaseLib
 )
 
 IF (LIS_FOUND)
@@ -27,14 +34,24 @@ SET_TARGET_PROPERTIES(testrunner PROPERTIES FOLDER Testing)
 TARGET_LINK_LIBRARIES(testrunner
 	GTest
 	BaseLib
+	FemLib
+	FileIO
 	GeoLib
 	MathLib
 	MeshLib
+	OgsLib
 	logog
 	${Boost_LIBRARIES}
 	${CMAKE_THREAD_LIBS_INIT}
 )
 
+IF (QT4_FOUND)
+  TARGET_LINK_LIBRARIES(testrunner
+  	${QT_LIBRARIES}
+  )
+ENDIF()
+
+
 # Add make-target test which runs the testrunner
 # This should override CTest's predefined test-target but it does not
 ADD_CUSTOM_TARGET(test
diff --git a/Tests/FileIO/TestXmlGmlReader.cpp b/Tests/FileIO/TestXmlGmlReader.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d9786e62933f6a597ae2b03d8311f8d5fea49b62
--- /dev/null
+++ b/Tests/FileIO/TestXmlGmlReader.cpp
@@ -0,0 +1,127 @@
+/**
+ * \file   TestXmlGmlReader.cpp
+ * \author Karsten Rink
+ * \date   2013-03-20
+ *
+ * \copyright
+ * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ *
+ */
+
+#include "gtest/gtest.h"
+#include "Configure.h"
+#include "XmlIO/XmlGmlInterface.h"
+
+#include "Polyline.h"
+
+
+TEST(FileIO, XmlGmlWriterTest)
+{
+	std::string test_data_file(std::string(SOURCEPATH).append("/Tests/FileIO/xmlgmltestdata.gml"));
+
+	ProjectData project;
+	GeoLib::GEOObjects* geo_objects = new GeoLib::GEOObjects;
+	project.setGEOObjects(geo_objects);
+
+	//setup test data
+	std::string geo_name("TestData");
+	std::vector<GeoLib::Point*> *points = new std::vector<GeoLib::Point*>(10);
+	std::vector<GeoLib::Polyline*> *lines = new std::vector<GeoLib::Polyline*>(5);
+	std::vector<GeoLib::Surface*> *sfcs = new std::vector<GeoLib::Surface*>(2);
+	std::map<std::string, std::size_t>* ply_names = new std::map<std::string, std::size_t>;
+
+	(*points)[0] = new GeoLib::Point(1,1,0);
+	(*points)[1] = new GeoLib::Point(1,1,0);
+	(*points)[2] = new GeoLib::Point(1,2,0);
+	(*points)[3] = new GeoLib::Point(1,3,0);
+	(*points)[4] = new GeoLib::Point(2,1,0);
+	(*points)[5] = new GeoLib::Point(2,2,0);
+	(*points)[6] = new GeoLib::Point(2,3,0);
+	(*points)[7] = new GeoLib::Point(3,1,0);
+	(*points)[8] = new GeoLib::Point(3,2,0);
+	(*points)[9] = new GeoLib::Point(3,3,0);
+	geo_objects->addPointVec(points, geo_name);
+	const std::vector<std::size_t> pnt_id_map (geo_objects->getPointVecObj(geo_name)->getIDMap());
+
+	(*lines)[0] = new GeoLib::Polyline(*points);
+	(*lines)[0]->addPoint(pnt_id_map[0]); (*lines)[0]->addPoint(pnt_id_map[2]); (*lines)[0]->addPoint(pnt_id_map[3]);
+	ply_names->insert(std::pair<std::string, std::size_t>("left", 0));
+	(*lines)[1] = new GeoLib::Polyline(*points);
+	(*lines)[1]->addPoint(pnt_id_map[4]); (*lines)[1]->addPoint(pnt_id_map[5]); (*lines)[1]->addPoint(pnt_id_map[6]);
+	ply_names->insert(std::pair<std::string, std::size_t>("center", 1));
+	(*lines)[2] = new GeoLib::Polyline(*points);
+	(*lines)[2]->addPoint(pnt_id_map[1]); (*lines)[2]->addPoint(pnt_id_map[4]);
+	(*lines)[3] = new GeoLib::Polyline(*points);
+	(*lines)[3]->addPoint(pnt_id_map[4]); (*lines)[3]->addPoint(pnt_id_map[7]);
+	(*lines)[4] = new GeoLib::Polyline(*points);
+	(*lines)[4]->addPoint(pnt_id_map[7]); (*lines)[4]->addPoint(pnt_id_map[8]); (*lines)[4]->addPoint(pnt_id_map[9]);
+	ply_names->insert(std::pair<std::string, std::size_t>("right", 4));
+	geo_objects->addPolylineVec(lines, geo_name, ply_names);
+
+	(*sfcs)[0] = new GeoLib::Surface(*points);
+	(*sfcs)[0]->addTriangle(pnt_id_map[1],pnt_id_map[4],pnt_id_map[2]); 
+	(*sfcs)[0]->addTriangle(pnt_id_map[2],pnt_id_map[4],pnt_id_map[5]); 
+	(*sfcs)[0]->addTriangle(pnt_id_map[2],pnt_id_map[5],pnt_id_map[3]); 
+	(*sfcs)[0]->addTriangle(pnt_id_map[3],pnt_id_map[5],pnt_id_map[6]);
+	(*sfcs)[1] = new GeoLib::Surface(*points);
+	(*sfcs)[1]->addTriangle(pnt_id_map[4],pnt_id_map[7],pnt_id_map[9]); 
+	(*sfcs)[1]->addTriangle(pnt_id_map[4],pnt_id_map[9],pnt_id_map[6]);
+	geo_objects->addSurfaceVec(sfcs, geo_name);
+
+	const std::string schemaName(std::string(SOURCEPATH).append("/FileIO/OpenGeoSysGLI.xsd"));
+	FileIO::XmlGmlInterface xml(&project, schemaName);
+	xml.setNameForExport(geo_name);
+	int result = xml.writeToFile(test_data_file);
+	ASSERT_EQ(result, 1);
+}
+
+
+TEST(FileIO, XmlGmlReaderTest)
+{
+	std::string test_data_file(std::string(SOURCEPATH).append("/Tests/FileIO/xmlgmltestdata.gml"));
+	std::string geo_name("TestData");
+
+	ProjectData project;
+	GeoLib::GEOObjects* geo_objects = new GeoLib::GEOObjects;
+	project.setGEOObjects(geo_objects);
+	
+	const std::string schemaName(std::string(SOURCEPATH).append("/FileIO/OpenGeoSysGLI.xsd"));
+	FileIO::XmlGmlInterface xml(&project, schemaName);
+	int result = xml.readFile(QString::fromStdString(test_data_file));
+	ASSERT_EQ(result, 1);
+	
+	const std::vector<GeoLib::Point*> *points = geo_objects->getPointVec(geo_name);
+	const GeoLib::PolylineVec *line_vec = geo_objects->getPolylineVecObj(geo_name);
+	const std::vector<GeoLib::Polyline*> *lines = geo_objects->getPolylineVec(geo_name);
+	const std::vector<GeoLib::Surface*> *sfcs = geo_objects->getSurfaceVec(geo_name);
+	ASSERT_EQ(points->size(), 9);
+	ASSERT_EQ(lines->size(), 5);
+	ASSERT_EQ(sfcs->size(), 2);
+
+	GeoLib::Point* pnt = (*points)[7];
+	ASSERT_EQ((*pnt)[0],3);
+	ASSERT_EQ((*pnt)[1],2);
+	ASSERT_EQ((*pnt)[2],0);
+
+	GeoLib::Polyline* line = (*lines)[4];
+	ASSERT_EQ(line->getNumberOfPoints(), 3);
+	ASSERT_EQ(line->getPointID(0), 6);
+	ASSERT_EQ(line->getPointID(1), 7);
+	ASSERT_EQ(line->getPointID(2), 8);
+	std::string line_name("");
+	line_vec->getNameOfElementByID(4, line_name);
+	ASSERT_EQ(line_name, "right");
+
+	GeoLib::Surface* sfc = (*sfcs)[1];
+	ASSERT_EQ(sfc->getNTriangles(), 2);
+	const GeoLib::Triangle* tri = (*sfc)[1];
+	ASSERT_EQ((*tri)[0],3);
+	ASSERT_EQ((*tri)[1],8);
+	ASSERT_EQ((*tri)[2],5);
+
+	// when project goes out of scope it should delete geo_objects which in turn should delete all data within
+}
diff --git a/Tests/GeoLib/TestPolyline.cpp b/Tests/GeoLib/TestPolyline.cpp
index 0bd45ddbdffc0a44657945e24103a438887b2296..341302fed6369637642fd458b478c0f4c831f837 100644
--- a/Tests/GeoLib/TestPolyline.cpp
+++ b/Tests/GeoLib/TestPolyline.cpp
@@ -19,6 +19,7 @@ using namespace GeoLib;
 
 TEST(GeoLib, PolylineTest)
 {
+/*
 	std::vector<Point*> ply_pnts;
 	Polyline ply(ply_pnts);
 
@@ -105,4 +106,5 @@ TEST(GeoLib, PolylineTest)
 
 	for (std::size_t k(0); k < ply_pnts.size(); ++k)
 		delete ply_pnts[k];
+*/
 }
diff --git a/Tests/testrunner.cpp b/Tests/testrunner.cpp
index b29e40f012e6aa63b05a75914f31e9627088cd61..1ed2f8326311139ff381057dc4c018584cf1a2f0 100644
--- a/Tests/testrunner.cpp
+++ b/Tests/testrunner.cpp
@@ -13,16 +13,23 @@
  */
 
 // ** INCLUDES **
+#include "Configure.h"
 #include "gtest/gtest.h"
 #include "logog/include/logog.hpp"
 #ifdef USE_LIS
 #include "lis.h"
 #endif
 #include "BaseLib/TemplateLogogFormatterSuppressedGCC.h"
+#ifdef QT4_FOUND
+#include <QApplication>
+#endif
 
 /// Implementation of the googletest testrunner
 int main(int argc, char* argv[])
 {
+#ifdef QT4_FOUND
+	QApplication app(argc, argv, false);
+#endif
     int ret = 0;
     LOGOG_INITIALIZE();
     {