diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java
index c8ba3eabbf138799791168b17a00b12e20d78bd9..6f7ef11e3f42878754fb6de4d4b1c43046d09f26 100644
--- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java
+++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java
@@ -66,28 +66,7 @@ public class TestRBase extends TestBase {
             String entryValue = entry.getValue();
             explicitTestContext = entryName;
             String[] lines = entryValue.split("\n");
-            String l = lines[0].trim();
-            TestTrait testTrait = null;
-            if (l.startsWith("#")) {
-                // check the first line for configuration options
-                if (l.contains("IgnoreErrorContext")) {
-                    testTrait = Output.IgnoreErrorContext;
-                } else if (l.contains("IgnoreWarningContext")) {
-                    testTrait = Output.IgnoreWarningContext;
-                } else if (l.contains("IgnoreWarningMessage")) {
-                    testTrait = Output.IgnoreWarningMessage;
-                } else if (l.contains("Ignored")) {
-                    for (Ignored ignoredType : Ignored.values()) {
-                        if (l.contains("Ignored." + ignoredType.name())) {
-                            testTrait = ignoredType;
-                            break;
-                        }
-                    }
-                    if (testTrait == null) {
-                        testTrait = Ignored.Unknown; // Retain old way for compatibility
-                    }
-                }
-            }
+            TestTrait testTrait = getTestTrait(lines);
             try {
                 Path dir = TestBase.createTestDir(getTestDir());
                 Path p = dir.resolve(Paths.get(entryName).getFileName());
@@ -103,4 +82,29 @@ public class TestRBase extends TestBase {
             explicitTestContext = null;
         }
     }
+
+    private static TestTrait getTestTrait(String[] lines) {
+        for (int i = 0; i < lines.length; i++) {
+            String l = lines[i].trim();
+            if (!l.startsWith("#")) {
+                return null;
+            }
+            // check the first line for configuration options
+            if (l.contains("IgnoreErrorContext")) {
+                return Output.IgnoreErrorContext;
+            } else if (l.contains("IgnoreWarningContext")) {
+                return Output.IgnoreWarningContext;
+            } else if (l.contains("IgnoreWarningMessage")) {
+                return Output.IgnoreWarningMessage;
+            } else if (l.contains("Ignored")) {
+                for (Ignored ignoredType : Ignored.values()) {
+                    if (l.contains("Ignored." + ignoredType.name())) {
+                        return ignoredType;
+                    }
+                }
+                return Ignored.Unknown; // Retain old way for compatibility
+            }
+        }
+        return null;
+    }
 }