better way to check if a dir exists
diff --git a/test/utils.py b/test/utils.py
index 7a3b83f..908cfcc 100644
--- a/test/utils.py
+++ b/test/utils.py
@@ -36,8 +36,7 @@
 def is_in_rootdir():
     """ Check whether the current dir is the root dir of pyelftools
     """
-    dirstuff = os.listdir('.')
-    return 'test' in dirstuff and 'elftools' in dirstuff
+    return os.path.isdir('test') and os.path.isdir('elftools')
 
 
 def dump_output_to_temp_files(testlog, *args):