diff --git a/tests/sys/fs/fusefs/fsync.cc b/tests/sys/fs/fusefs/fsync.cc
index b283f065c1ff..5f0834de482a 100644
--- a/tests/sys/fs/fusefs/fsync.cc
+++ b/tests/sys/fs/fusefs/fsync.cc
@@ -80,8 +80,17 @@ void expect_write(uint64_t ino, uint64_t size, const void *contents)
 
 };
 
+class AioFsync: public Fsync {
+virtual void SetUp() {
+	if (!is_unsafe_aio_enabled())
+		GTEST_SKIP() <<
+			"vfs.aio.enable_unsafe must be set for this test";
+	FuseTest::SetUp();
+}
+};
+
 /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236379 */
-TEST_F(Fsync, aio_fsync)
+TEST_F(AioFsync, aio_fsync)
 {
 	const char FULLPATH[] = "mountpoint/some_file.txt";
 	const char RELPATH[] = "some_file.txt";
diff --git a/tests/sys/fs/fusefs/fsyncdir.cc b/tests/sys/fs/fusefs/fsyncdir.cc
index b87f8c47a2e5..2d6da44ccece 100644
--- a/tests/sys/fs/fusefs/fsyncdir.cc
+++ b/tests/sys/fs/fusefs/fsyncdir.cc
@@ -75,8 +75,17 @@ void expect_lookup(const char *relpath, uint64_t ino)
 
 };
 
+class AioFsyncDir: public FsyncDir {
+virtual void SetUp() {
+	if (!is_unsafe_aio_enabled())
+		GTEST_SKIP() <<
+			"vfs.aio.enable_unsafe must be set for this test";
+	FuseTest::SetUp();
+}
+};
+
 /* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236379 */
-TEST_F(FsyncDir, aio_fsync)
+TEST_F(AioFsyncDir, aio_fsync)
 {
 	const char FULLPATH[] = "mountpoint/some_file.txt";
 	const char RELPATH[] = "some_file.txt";
diff --git a/tests/sys/fs/fusefs/read.cc b/tests/sys/fs/fusefs/read.cc
index bf0641738fca..047e629ea187 100644
--- a/tests/sys/fs/fusefs/read.cc
+++ b/tests/sys/fs/fusefs/read.cc
@@ -71,17 +71,10 @@ void expect_lookup(const char *relpath, uint64_t ino, uint64_t size)
 class AioRead: public Read {
 public:
 virtual void SetUp() {
-	const char *node = "vfs.aio.enable_unsafe";
-	int val = 0;
-	size_t size = sizeof(val);
-
-	FuseTest::SetUp();
-
-	ASSERT_EQ(0, sysctlbyname(node, &val, &size, NULL, 0))
-		<< strerror(errno);
-	if (!val)
+	if (!is_unsafe_aio_enabled())
 		GTEST_SKIP() <<
 			"vfs.aio.enable_unsafe must be set for this test";
+	FuseTest::SetUp();
 }
 };
 
diff --git a/tests/sys/fs/fusefs/utils.cc b/tests/sys/fs/fusefs/utils.cc
index c2451fc8bdc8..ac0f6e29f804 100644
--- a/tests/sys/fs/fusefs/utils.cc
+++ b/tests/sys/fs/fusefs/utils.cc
@@ -87,6 +87,18 @@ void check_environment()
 		GTEST_SKIP() << "current user is not allowed to mount";
 }
 
+bool is_unsafe_aio_enabled(void) {
+	const char *node = "vfs.aio.enable_unsafe";
+	int val = 0;
+	size_t size = sizeof(val);
+
+	if (sysctlbyname(node, &val, &size, NULL, 0)) {
+		perror("sysctlbyname");
+		return (false);
+	}
+	return (val != 0);
+}
+
 class FuseEnv: public Environment {
 	virtual void SetUp() {
 	}
diff --git a/tests/sys/fs/fusefs/utils.hh b/tests/sys/fs/fusefs/utils.hh
index 6fe870c091f6..3f82b184d54b 100644
--- a/tests/sys/fs/fusefs/utils.hh
+++ b/tests/sys/fs/fusefs/utils.hh
@@ -42,6 +42,8 @@ inline void nap()
 	usleep(NAP_NS / 1000);
 }
 
+bool is_unsafe_aio_enabled(void);
+
 extern const uint32_t libfuse_max_write;
 extern const uint32_t default_max_write;
 class FuseTest : public ::testing::Test {
diff --git a/tests/sys/fs/fusefs/write.cc b/tests/sys/fs/fusefs/write.cc
index 0f010d564824..e18d2b06013e 100644
--- a/tests/sys/fs/fusefs/write.cc
+++ b/tests/sys/fs/fusefs/write.cc
@@ -33,7 +33,6 @@ extern "C" {
 #include <sys/mman.h>
 #include <sys/resource.h>
 #include <sys/stat.h>
-#include <sys/sysctl.h>
 #include <sys/time.h>
 #include <sys/uio.h>
 
@@ -136,17 +135,10 @@ void expect_lookup(const char *relpath, uint64_t ino, uint64_t size)
 
 class AioWrite: public Write {
 virtual void SetUp() {
-	const char *node = "vfs.aio.enable_unsafe";
-	int val = 0;
-	size_t size = sizeof(val);
-
-	FuseTest::SetUp();
-
-	ASSERT_EQ(0, sysctlbyname(node, &val, &size, NULL, 0))
-		<< strerror(errno);
-	if (!val)
+	if (!is_unsafe_aio_enabled())
 		GTEST_SKIP() <<
 			"vfs.aio.enable_unsafe must be set for this test";
+	FuseTest::SetUp();
 }
 };