diff --git a/tests/config/keyfile/bad_parameters.args b/tests/config/keyfile/bad_parameters.args
new file mode 100644
index 0000000000000000000000000000000000000000..6661ce0078691209a9a3fdc85730107bdfee3e94
--- /dev/null
+++ b/tests/config/keyfile/bad_parameters.args
@@ -0,0 +1 @@
+--keyfile-ro root.keys --keyfile root.keys
\ No newline at end of file
diff --git a/tests/config/keyfile/bad_parameters.cfg b/tests/config/keyfile/bad_parameters.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..a45213dedcc5e970cfd19aa8ce773116e40d32c7
--- /dev/null
+++ b/tests/config/keyfile/bad_parameters.cfg
@@ -0,0 +1,3 @@
+dofile('./test_utils.lua') -- load test utilities
+
+quit()
diff --git a/tests/config/keyfile/bad_parameters.returncode b/tests/config/keyfile/bad_parameters.returncode
new file mode 100644
index 0000000000000000000000000000000000000000..56a6051ca2b02b04ef92d5150c9ef600403cb1de
--- /dev/null
+++ b/tests/config/keyfile/bad_parameters.returncode
@@ -0,0 +1 @@
+1
\ No newline at end of file
diff --git a/tests/config/keyfile/root1.keys b/tests/config/keyfile/root1.keys
new file mode 100644
index 0000000000000000000000000000000000000000..c7343371b9f01ac3ca7540d75044e02a56c86350
--- /dev/null
+++ b/tests/config/keyfile/root1.keys
@@ -0,0 +1 @@
+.                   	172800	DNSKEY	257 3 8 AwEAAagAIKlVZrpC6Ia7gEzahOR+9W29euxhJhVVLOyQbSEW0O8gcCjFFVQUTf6v58fLjwBd0YI0EzrAcQqBGCzh/RStIoO8g0NfnfL2MTJRkxoXbfDaUeVPQuYEhg37NZWAJQ9VnMVDxP/VHL496M/QZxkjf5/Efucp2gaDX6RS6CXpoY68LsvPVjR0ZSwzz1apAzvN9dlzEheX7ICJBBtuA6G3LQpzW5hOA2hzCTMjJPJ8LbqF6dsV6DoBQzgul0sGIcGOYl7OyQdXfZ57relSQageu+ipAdTTJ25AsRTAoub8ONGcLmqrAmRLKBP1dfwhYB4N7knNnulqQxA+Uk1ihz0= ; Valid: ; KeyTag:19036
diff --git a/tests/config/keyfile/root2.keys b/tests/config/keyfile/root2.keys
new file mode 100644
index 0000000000000000000000000000000000000000..5e9d6ac6e0e3964863dd4ea98280e1eb1fb5862e
--- /dev/null
+++ b/tests/config/keyfile/root2.keys
@@ -0,0 +1 @@
+.                   	172800	DNSKEY	257 3 8 AwEAAaz/tAm8yTn4Mfeh5eyI96WSVexTBAvkMgJzkKTOiW1vkIbzxeF3+/4RgWOq7HrxRixHlFlExOLAJr5emLvN7SWXgnLh4+B5xQlNVz8Og8kvArMtNROxVQuCaSnIDdD5LKyWbRd2n9WGe2R8PzgCmr3EgVLrjyBxWezF0jLHwVN8efS3rCj/EWgvIWgb9tarpVUDK/b58Da+sqqls3eNbuv7pr+eoZG+SrDK6nWeL3c6H5Apxz7LjVc1uTIdsIXxuOLYA4/ilBmSVIzuDWfdRUfhHdY6+cn8HFRm+2hM8AnXGXws9555KrUB5qihylGa8subX2Nn6UwNR1AkUTV74bU= ; Valid: ; KeyTag:20326
diff --git a/tests/config/keyfile/test.args b/tests/config/keyfile/test.args
new file mode 100644
index 0000000000000000000000000000000000000000..2d1897de7882fc62dca4dca0620ab8e9aa9d1c47
--- /dev/null
+++ b/tests/config/keyfile/test.args
@@ -0,0 +1 @@
+--keyfile-ro root2.keys
\ No newline at end of file
diff --git a/tests/config/keyfile/test.cfg b/tests/config/keyfile/test.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..2f1ff20a559e0d3ca2856f138578ad742b1b4e98
--- /dev/null
+++ b/tests/config/keyfile/test.cfg
@@ -0,0 +1,48 @@
+dofile('./test_utils.lua') -- load test utilities
+
+-- test fixtures
+
+-- count warning message, fail with other than allowed message
+warn_msg = {}
+overriding_msg="[ ta ] warning: overriding previously set trust anchors for ."
+warn_msg[overriding_msg] = 0
+function warn(fmt, ...)        
+	msg = string.format(fmt, ...)
+	if warn_msg[msg] == nil then
+		fail("Not allowed warn message: %s", msg)
+	else 
+		warn_msg[msg] = warn_msg[msg] + 1
+	end
+end
+
+-- test
+if pcall(trust_anchors.add_file, 'nonwriteable/root.keys', false) then
+	fail("Managed trsut anchor file in directory without write access should fail")
+end
+
+if pcall(trust_anchors.add_file, 'nonexist.keys', true) then
+	fail("Nonexist unmanaged file should fail")
+end
+
+trust_anchors.add_file('root2.keys', true)
+
+trust_anchors.add_file('root1.keys', true)
+if warn_msg[overriding_msg] ~= 1 then 
+	fail("Missing warning message for override: %s", overriding_msg)
+end
+
+if trust_anchors.keysets['\0'][1].key_tag ~= 19036 then
+	fail("Not loaded or loaded trust anchor from root1.keys")
+end
+
+-- run test after processed config file
+ev = event.after(0, function (ev) 
+        -- check overiding trust anchor from cmdline args
+	if trust_anchors.keysets['\0'][1].key_tag ~= 20326 then
+		fail("Not loaded or loaded trust anchor from root2.keys")
+	end
+	if warn_msg[overriding_msg] ~= 2 then 
+		fail("Missing warning message for override: %s", overriding_msg)
+	end
+        quit()
+end)
diff --git a/tests/config/test_utils.lua b/tests/config/test_utils.lua
index 3c2c63271e6f5a08f5cb909214e939276135fc76..edec11f713ab3d37b77436d32f56f953bb766d42 100644
--- a/tests/config/test_utils.lua
+++ b/tests/config/test_utils.lua
@@ -38,4 +38,4 @@ function M.not_contains(table, value, message)
 	return contains(fail, pass, table, value, message)
 end
 
-return M
\ No newline at end of file
+return M