diff --git a/src/main/java/org/olat/course/CourseFactory.java b/src/main/java/org/olat/course/CourseFactory.java
index c62078cc52e841cd171fc4c07b2928d7643c339b..046ea8d4851eb050e1f30289f5b0602a9d76957a 100644
--- a/src/main/java/org/olat/course/CourseFactory.java
+++ b/src/main/java/org/olat/course/CourseFactory.java
@@ -368,7 +368,7 @@ public class CourseFactory extends BasicManager {
 	 * 
 	 * @param res
 	 */
-	public static void deleteCourse(OLATResourceable res) {
+	public static void deleteCourse(OLATResource res) {
 		final long start = System.currentTimeMillis();
 		log.info("deleteCourse: starting to delete course. res="+res);
 
@@ -406,10 +406,8 @@ public class CourseFactory extends BasicManager {
 			CourseConfigManagerImpl.getInstance().deleteConfigOf(course);
 		}
 		
-		//clean up tasks
-		OLATResource resource = course.getCourseEnvironment().getCourseGroupManager().getCourseResource();
-		CoreSpringFactory.getImpl(TaskExecutorManager.class).delete(resource);
-		
+		CoreSpringFactory.getImpl(TaskExecutorManager.class).delete(res);
+
 		// delete course group- and rightmanagement
 		CourseGroupManager courseGroupManager = PersistingCourseGroupManager.getInstance(res);
 		courseGroupManager.deleteCourseGroupmanagement();
diff --git a/src/main/java/org/olat/repository/handlers/CourseHandler.java b/src/main/java/org/olat/repository/handlers/CourseHandler.java
index 24f38fedb867b82c3db07a637a94f94178383cd9..53dcbeac36ebabb2a97fe9ec7195daa013088b1c 100644
--- a/src/main/java/org/olat/repository/handlers/CourseHandler.java
+++ b/src/main/java/org/olat/repository/handlers/CourseHandler.java
@@ -220,11 +220,12 @@ public class CourseHandler implements RepositoryHandler {
 	public boolean cleanupOnDelete(OLATResourceable res) {
 		// notify all current users of this resource (course) that it will be deleted now.
 		CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new OLATResourceableJustBeforeDeletedEvent(res), res);
-		//archiving is done within readyToDelete		
-		CourseFactory.deleteCourse(res);
-		// delete resourceable
+		
 		OLATResourceManager rm = OLATResourceManager.getInstance();
 		OLATResource ores = rm.findResourceable(res);
+		//archiving is done within readyToDelete		
+		CourseFactory.deleteCourse(ores);
+		// delete resource
 		rm.deleteOLATResource(ores);
 		return true;
 	}
diff --git a/src/test/java/org/olat/course/auditing/UserNodeAuditManagerTest.java b/src/test/java/org/olat/course/auditing/UserNodeAuditManagerTest.java
index b20ca4cfe254f700cf20103aaace9645565d13af..280640bcd60f614bbbb8cfbd4bfb10615da9e9c3 100644
--- a/src/test/java/org/olat/course/auditing/UserNodeAuditManagerTest.java
+++ b/src/test/java/org/olat/course/auditing/UserNodeAuditManagerTest.java
@@ -30,11 +30,8 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import org.junit.Before;
 import org.junit.Test;
 import org.olat.core.commons.persistence.DBFactory;
-import org.olat.core.logging.OLog;
-import org.olat.core.logging.Tracing;
 import org.olat.course.CourseFactory;
 import org.olat.course.ICourse;
 import org.olat.repository.RepositoryEntry;
@@ -45,44 +42,18 @@ import org.olat.test.OlatTestCase;
  * @author Christian Guretzki
  */
 public class UserNodeAuditManagerTest extends OlatTestCase  {
-	
-	private static OLog log = Tracing.createLoggerFor(UserNodeAuditManagerTest.class);
-	
-	private ICourse course;
 
-	
-	@Before
-	public void setUp() throws Exception {		
-		try {
-			log.info("setUp start ------------------------");
-			
-      //import "Demo course" into the bcroot_junittest
-			RepositoryEntry repositoryEntry = JunitTestHelper.deployDemoCourse();
-			Long resourceableId = repositoryEntry.getOlatResource().getResourceableId();
-			System.out.println("Demo course imported - resourceableId: " + resourceableId);
-					
-			course = CourseFactory.loadCourse(resourceableId);
-			DBFactory.getInstance().closeSession();
-						
-			log.info("setUp done ------------------------");					
-		} catch (RuntimeException e) {
-			log.error("Exception in setUp(): " + e);
-			e.printStackTrace();
-		}
-	}
 
-	//@After
-	public void tearDown() throws Exception {			
-		//remove demo course on file system
-		//FIXME: this does not remove all data from the database, see repositoryManger
-		CourseFactory.deleteCourse(course);
-	}
-	
-	/**
-	 * 
-	 *
-	 */
-	@Test public void testCreateLimitedLogContent() {
+	@Test
+	public void testCreateLimitedLogContent() {
+		//import a course
+		RepositoryEntry repositoryEntry = JunitTestHelper.deployDemoCourse();
+		Long resourceableId = repositoryEntry.getOlatResource().getResourceableId();
+		System.out.println("Demo course imported - resourceableId: " + resourceableId);	
+		ICourse course = CourseFactory.loadCourse(resourceableId);
+		DBFactory.getInstance().commitAndCloseSession();
+
+		
 		System.out.println("Start testCreateLimitedLogContent");
 		assertNotNull(course);
 		UserNodeAuditManagerImpl userNodeAuditManagerImpl = new UserNodeAuditManagerImpl(course);