The suite specific header should only be used when the suite is active
diff --git a/tests/scripts/generate_code.pl b/tests/scripts/generate_code.pl
index 40f993f..1e33ac6 100755
--- a/tests/scripts/generate_code.pl
+++ b/tests/scripts/generate_code.pl
@@ -61,7 +61,9 @@
 print TEST_FILE << "END";
 #include <polarssl/config.h>
 
+$suite_pre_code
 $suite_header
+$suite_post_code
 
 $test_helpers
 
diff --git a/tests/suites/main_test.function b/tests/suites/main_test.function
index 4a34319..d5aa386 100644
--- a/tests/suites/main_test.function
+++ b/tests/suites/main_test.function
@@ -3,6 +3,9 @@
 
 static int test_errors = 0;
 
+SUITE_PRE_DEP
+#define TEST_SUITE_ACTIVE
+
 static int test_assert( int correct, char *test )
 {
     if( correct )
@@ -81,6 +84,9 @@
     return( -1 );
 }
 
+FUNCTION_CODE
+SUITE_POST_DEP
+
 int dep_check( char *str )
 {
     if( str == NULL )
@@ -91,11 +97,6 @@
     return( 1 );
 }
 
-SUITE_PRE_DEP
-#define TEST_SUITE_ACTIVE
-FUNCTION_CODE
-SUITE_POST_DEP
-
 int dispatch_test(int cnt, char *params[50])
 {
     int ret;