added unittests
bugfix memoryleak