diff --git a/tests/pydnstest/scenario.py b/tests/pydnstest/scenario.py
index ca78814e07f495f1b5cf22635ccdbb6323448c2b..a0f22ff736929928da2dffc3dd2ca733455277f9 100644
--- a/tests/pydnstest/scenario.py
+++ b/tests/pydnstest/scenario.py
@@ -336,15 +336,19 @@ class Step:
 
     def __time_passes(self, ctx):
         """ Modify system time. """
-        ctx.time += int(self.args[1])
+        time_file = open(os.environ["FAKETIME_TIMESTAMP_FILE"], 'r')
+        line = time_file.readline().strip()
+        time_file.close()
+        t = time.mktime(datetime.strptime(line, '%Y-%m-%d %H:%M:%S').timetuple())
+        t += int(self.args[1])
         time_file = open(os.environ["FAKETIME_TIMESTAMP_FILE"], 'w')
-        time_file.write(datetime.fromtimestamp(ctx.time).strftime('%Y-%m-%d %H:%M:%S') + "\n")
+        time_file.write(datetime.fromtimestamp(t).strftime('%Y-%m-%d %H:%M:%S') + "\n")
+        time_file.close()
 
 class Scenario:
     def __init__(self, info):
         """ Initialize scenario with description. """
         self.info = info
-        self.time = 0
         self.ranges = []
         self.steps = []
         self.current_step = None
@@ -397,5 +401,5 @@ class Scenario:
         except Exception as e:
             raise Exception('step #%d %s' % (step.id, str(e)))
         finally:
-        	self.child_sock.close()
-        	self.child_sock = None
+            self.child_sock.close()
+            self.child_sock = None
diff --git a/tests/test_integration.py b/tests/test_integration.py
index bf6510b26463feff5b3fcd2198a1c8bc4526fddc..172c0c5eb1d3815d33a2c861e2c84e1fd9a01954 100755
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -167,6 +167,11 @@ def find_objects(path):
             result.append(path)
     return result
 
+def write_timestamp_file(path, tst):
+    time_file = open(path, 'w')
+    time_file.write(datetime.fromtimestamp(tst).strftime('%Y-%m-%d %H:%M:%S'))
+    time_file.close()
+
 def setup_env(child_env, config, config_name, j2template):
     """ Set up test environment and config """
     # Clear test directory
@@ -174,9 +179,9 @@ def setup_env(child_env, config, config_name, j2template):
     # Set up libfaketime
     os.environ["FAKETIME_NO_CACHE"] = "1"
     os.environ["FAKETIME_TIMESTAMP_FILE"] = '%s/.time' % TMPDIR
-    time_file = open(os.environ["FAKETIME_TIMESTAMP_FILE"], 'w')
-    time_file.write(datetime.fromtimestamp(0).strftime('%Y-%m-%d %H:%M:%S'))
-    time_file.close()
+    child_env["FAKETIME_NO_CACHE"] = "1"
+    child_env["FAKETIME_TIMESTAMP_FILE"] = '%s/.time' % TMPDIR
+    write_timestamp_file(child_env["FAKETIME_TIMESTAMP_FILE"], 0)
     # Set up child process env() 
     child_env["SOCKET_WRAPPER_DEFAULT_IFACE"] = "%i" % CHILD_IFACE
     child_env["SOCKET_WRAPPER_DIR"] = TMPDIR
@@ -188,9 +193,16 @@ def setup_env(child_env, config, config_name, j2template):
             no_minimize = "false"
         elif k == 'trust-anchor':
             if ((v[0] == '"') and (v[-1] == '"')) or ((v[0] == '\'') and (v[-1] == '\'')):
-                trust_anchor = v[1:-1]
+                trust_anchor_str = v[1:-1]
+            else:
+                trust_anchor_str = v
+        elif k == 'val-override-date':
+            override_date_str = ""
+            if ((v[0] == '"') and (v[-1] == '"')) or ((v[0] == '\'') and (v[-1] == '\'')):
+                override_date_str = v[1:-1]
             else:
-                trust_anchor = v
+                override_date_str = v
+            write_timestamp_file(child_env["FAKETIME_TIMESTAMP_FILE"], int(override_date_str))
     selfaddr = testserver.get_local_addr_str(socket.AF_INET, DEFAULT_IFACE)
     childaddr = testserver.get_local_addr_str(socket.AF_INET, CHILD_IFACE)
     # Prebind to sockets to create necessary files
@@ -206,7 +218,7 @@ def setup_env(child_env, config, config_name, j2template):
         "ROOT_ADDR" : selfaddr,
         "SELF_ADDR" : childaddr,
         "NO_MINIMIZE" : no_minimize,
-        "TRUST_ANCHOR" : trust_anchor,
+        "TRUST_ANCHOR" : trust_anchor_str,
         "WORKING_DIR" : TMPDIR,
     }
     cfg_rendered = j2template.render(j2template_ctx)