Refactoring of resends and extra test functions + valgrind check on testclass