diff --git a/pystencils_tests/test_opencl.py b/pystencils_tests/test_opencl.py
index a5459b8f0750d54c2bb85061fc6accacde023214..69c85678d62cf2b4785895b00d0fe97dfa4701b6 100644
--- a/pystencils_tests/test_opencl.py
+++ b/pystencils_tests/test_opencl.py
@@ -10,6 +10,8 @@ from pystencils.opencl.opencljit import get_global_cl_queue, make_python_functio
 try:
     import pyopencl as cl
     HAS_OPENCL = True
+    import pystencils.opencl.autoinit
+
 except Exception:
     HAS_OPENCL = False
 
@@ -246,9 +248,6 @@ def test_kernel_creation():
 
     print(assignments)
 
-    pystencils.opencl.clear_global_ctx()
-
-    import pystencils.opencl.autoinit
     ast = pystencils.create_kernel(assignments, target='opencl')
 
     print(ast.backend)