diff --git a/SAS/OTDB_Services/test/t_TreeStatusEvents.py b/SAS/OTDB_Services/test/t_TreeStatusEvents.py
index 5f1df337961b660fed3ac91d748bb1766611f79a..100bf4cf4837f2ce030e485759657e732fe0febd 100644
--- a/SAS/OTDB_Services/test/t_TreeStatusEvents.py
+++ b/SAS/OTDB_Services/test/t_TreeStatusEvents.py
@@ -32,6 +32,8 @@ from lofar.messaging.messagebus import *
 from lofar.sas.otdb.TreeStatusEvents import create_service
 import threading
 import sys
+from datetime import datetime, timedelta
+from tempfile import NamedTemporaryFile
 
 import logging
 logger = logging.getLogger(__name__)
@@ -44,17 +46,22 @@ with OTDBTestInstance('t_TreeStatusEvents.in.unittest_db.dump.gz') as test_db:
         with tmp_exchange.create_temporary_queue() as tmp_queue:
             with tmp_queue.create_frombus() as frombus:
 
-                t = threading.Thread(target=create_service, args=(tmp_exchange.address, test_db.dbcreds, '/dev/null'))
-                t.daemon = True
-                t.start()
+                with NamedTemporaryFile(mode='w+') as state_file:
+                    state_file.file.write((datetime.utcnow()-timedelta(seconds=2)).strftime("%Y-%m-%d %H:%M:%S"))
+                    state_file.file.flush()
 
-                test_db.db.executeQuery("select setTreeState(1, %d, %d::INT2,'%s'::boolean);" % (1099266, 500, False))
-                test_db.db.commit()
+                    t = threading.Thread(target=create_service, args=(tmp_exchange.address, test_db.dbcreds, state_file.name))
+                    t.daemon = True
+                    t.start()
 
-                msg = frombus.receive(timeout=500, acknowledge=True)	  # TreeStateEvent are send every 2 seconds
-                logger.info(msg)
-                try:
-                    ok = (msg.content['treeID'] == 1099266 and msg.content['state'] == 'queued')
-                except IndexError:
-                    ok = False
-    sys.exit(not ok)   # 0 = success
+                    test_db.db.executeQuery("select setTreeState(1, %d, %d::INT2,'%s'::boolean);" % (1099266, 500, False))
+                    test_db.db.commit()
+
+                    msg = frombus.receive(timeout=500, acknowledge=True)	  # TreeStateEvent are send every 2 seconds
+                    logger.info(msg)
+                    try:
+                        ok = (msg.content['treeID'] == 1099266 and msg.content['state'] == 'queued')
+                    except IndexError:
+                        ok = False
+
+sys.exit(not ok)   # 0 = success