diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 55f5e1b9cf3c831e3fabd300d6494c46ff35eae9..4d4b4d7572435f8e8d11e99a51230bc3c97db712 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -18,23 +18,10 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program. If not, see <https://www.gnu.org/licenses/>.
 
-variables:
-   CI_REGISTRY_IMAGE: $CI_REGISTRY/caosdb/src/caosdb-pyinttest/testenv:latest
-   CI_REGISTRY_IMAGE_BASE: $CI_REGISTRY/caosdb/src/caosdb-pyinttest/base:latest
-   DEPLOY_REF: dev
-
-stages:
-  - setup
-  - cert
-  - style
-  - test
-  - deploy
-
 
-# During the test stage the CI pipeline (which runs in a "root" docker) starts
-# two docker containers with docker-compose (one for the caosdb-server, another
-# for the mysql-backend). Then a third docker is being started which contains
-# the pyintest suite and executes it.
+# During the test stage the CI pipeline (which runs in a "root" docker) starts two docker containers
+# with docker-compose (one for the caosdb-server, another for the mysql-backend). Then a third
+# docker is started which contains the pyintest suite and runs the integration tests.
 #
 # +-------------(root docker)-------------------------+
 # |                                                   |
@@ -44,8 +31,8 @@ stages:
 # |             +-(caosdb-server)-------------------+ |
 # |             |                                   | |
 # |             | /opt/caosdb                       | |
-# |    .------->|  + /git/caosdb-server/scripting/  | |
-# |    | .----->|  + /git/caosdb-server/authtoken/  | |
+# |    .------->|  + /git/caosdb-server/authtoken/  | |
+# |    | .----->|  + /git/caosdb-server/scripting/  | |
 # |    | | .--->|  + /mnt/extroot                   | |
 # |    | | | .->|  + /cert                          | |
 # |    | | | |  |                                   | |
@@ -79,6 +66,79 @@ stages:
 # file-system features.
 #
 
+variables:
+   CI_REGISTRY_IMAGE: $CI_REGISTRY/caosdb/src/caosdb-pyinttest/testenv:latest
+   CI_REGISTRY_IMAGE_BASE: $CI_REGISTRY/caosdb/src/caosdb-pyinttest/base:latest
+   DEPLOY_REF: dev
+
+stages:
+  - setup
+  - cert
+  - style
+  - test
+  - deploy
+
+
+build-testenv:
+  tags: [cached-dind]
+  image: docker:19.03
+  stage: setup
+  timeout: 2h
+  only:
+    - schedules
+    - web
+    - pushes
+  needs: []
+  script:
+      - df -h
+      - command -v wget
+      - if [ -z "$PYLIB" ]; then
+          if echo "$CI_COMMIT_REF_NAME" | grep -c "^f-" ; then
+            echo "Check if pylib has branch $CI_COMMIT_REF_NAME" ;
+            if wget https://gitlab.com/api/v4/projects/13656973/repository/branches/${CI_COMMIT_REF_NAME} ; then
+              PYLIB=$CI_COMMIT_REF_NAME ;
+            fi;
+          fi;
+        fi;
+      - PYLIB=${PYLIB:-dev}
+      - echo $PYLIB
+
+      - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+        # use here general latest or specific branch latest...
+      - docker build 
+        --build-arg PYLIB=${PYLIB}
+        --file .docker/Dockerfile
+        -t $CI_REGISTRY_IMAGE .
+      - docker push $CI_REGISTRY_IMAGE
+      - docker save $CI_REGISTRY_IMAGE > /image-cache/caosdb-pyint-testenv-${CI_COMMIT_REF_NAME}.tar
+      - cd .docker-base
+      - docker build 
+        -t $CI_REGISTRY_IMAGE_BASE .
+      - docker push $CI_REGISTRY_IMAGE_BASE
+
+
+cert:
+  tags: [docker]
+  stage: cert
+  image: $CI_REGISTRY_IMAGE
+  artifacts:
+    paths:
+      - .docker/cert/
+    expire_in: 1 week
+  script:
+      - cd .docker
+      - CAOSHOSTNAME=caosdb-server ./cert.sh
+
+
+style:
+  tags: [docker]
+  stage: style
+  image: $CI_REGISTRY_IMAGE
+  script:
+      - autopep8 -r --diff --exit-code .
+  allow_failure: true
+
+
 test:
   tags: [docker]
   services:
@@ -153,63 +213,8 @@ test:
       - .docker/hash_*
     expire_in: 1 week
 
-build-testenv:
-  tags: [cached-dind]
-  image: docker:19.03
-  stage: setup
-  timeout: 2h
-  only:
-    - schedules
-    - web
-    - pushes
-  needs: []
-  script:
-      - df -h
-      - command -v wget
-      - if [ -z "$PYLIB" ]; then
-          if echo "$CI_COMMIT_REF_NAME" | grep -c "^f-" ; then
-            echo "Check if pylib has branch $CI_COMMIT_REF_NAME" ;
-            if wget https://gitlab.com/api/v4/projects/13656973/repository/branches/${CI_COMMIT_REF_NAME} ; then
-              PYLIB=$CI_COMMIT_REF_NAME ;
-            fi;
-          fi;
-        fi;
-      - PYLIB=${PYLIB:-dev}
-      - echo $PYLIB
-
-      - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
-        # use here general latest or specific branch latest...
-      - docker build 
-        --build-arg PYLIB=${PYLIB}
-        --file .docker/Dockerfile
-        -t $CI_REGISTRY_IMAGE .
-      - docker push $CI_REGISTRY_IMAGE
-      - docker save $CI_REGISTRY_IMAGE > /image-cache/caosdb-pyint-testenv-${CI_COMMIT_REF_NAME}.tar
-      - cd .docker-base
-      - docker build 
-        -t $CI_REGISTRY_IMAGE_BASE .
-      - docker push $CI_REGISTRY_IMAGE_BASE
-
-cert:
-  tags: [docker]
-  stage: cert
-  image: $CI_REGISTRY_IMAGE
-  artifacts:
-    paths:
-      - .docker/cert/
-    expire_in: 1 week
-  script:
-      - cd .docker
-      - CAOSHOSTNAME=caosdb-server ./cert.sh
-style:
-  tags: [docker]
-  stage: style
-  image: $CI_REGISTRY_IMAGE
-  script:
-      - autopep8 -r --diff --exit-code .
-  allow_failure: true
-
 
+# Deploy: Store working revision combinations to https://caosdb.org/revisions
 store-version:
   tags: [docker]
   stage: deploy