 
 (deftest add-user-test
   (let [session (login! app)
-        response (-> (request :post "/api/congregations")
-                     (json-body {:name "Congregation"})
-                     (merge session)
-                     app
-                     (assert-response ok?))
-        cong-id (UUID/fromString (:id (:body response)))
+        cong-id (create-congregation! session "Congregation")
         new-user-id (db/with-db [conn {}]
                       (user/save-user! conn "user1" {:name "User 1"}))]
 
     (testing "add user"
-      (let [response (-> (request :post (str "/api/congregation/" cong-id "/add-user"))
-                         (json-body {:userId (str new-user-id)})
-                         (merge session)
-                         app)]
-        (is (ok? response)))
-      ;; TODO: check the result through the API
-      (let [users (congregation/get-users (projections/cached-state) cong-id)]
-        (is (contains? (set users) new-user-id))))
+      (let [response (try-add-user! session cong-id new-user-id)]
+        (is (ok? response))
+        ;; TODO: check the result through the API
+        (let [users (congregation/get-users (projections/cached-state) cong-id)]
+          (is (contains? (set users) new-user-id)))))
 
     (testing "invalid user"
-      (let [response (-> (request :post (str "/api/congregation/" cong-id "/add-user"))
-                         (json-body {:userId (str (UUID. 0 1))})
-                         (merge session)
-                         app)]
+      (let [response (try-add-user! session cong-id (UUID. 0 1))]
         (is (bad-request? response))
         (is (= {:errors [["no-such-user" "00000000-0000-0000-0000-000000000001"]]}
                (:body response)))))
 
     (testing "no access"
       (revoke-access-from-all! cong-id)
-      (let [response (-> (request :post (str "/api/congregation/" cong-id "/add-user"))
-                         (json-body {:userId (str new-user-id)})
-                         (merge session)
-                         app)]
+      (let [response (try-add-user! session cong-id new-user-id)]
         (is (forbidden? response))))))
 
 (deftest set-user-permissions-test
   (let [session (login! app)
-        response (-> (request :post "/api/congregations")
-                     (json-body {:name "Congregation"})
-                     (merge session)
-                     app
-                     (assert-response ok?))
-        cong-id (UUID/fromString (:id (:body response)))
+        cong-id (create-congregation! session "Congregation")
         user-id (db/with-db [conn {}]
                   (user/save-user! conn "user1" {:name "User 1"}))]
-    (let [response (-> (request :post (str "/api/congregation/" cong-id "/add-user"))
-                       (json-body {:userId (str user-id)})
-                       (merge session)
-                       app)]
-      (is (ok? response)))
+    (is (ok? (try-add-user! session cong-id user-id)))
 
     ;; TODO: test changing permissions (after new users no more get full admin access)?
 


(deftest get-demo-congregation-test
  (let [session (login! app)
        response (-> (request :post "/api/congregations")
                     (json-body {:name "foo"})
                     (merge session)
                     app
                     (assert-response ok?))
        cong-id (UUID/fromString (:id (:body response)))]
    (binding [config/env (assoc config/env :demo-congregation cong-id)]

      (testing "get demo congregation"


(deftest rename-congregation-test
  (let [session (login! app)
        cong-id (create-congregation! session "Old Name")]

    (testing "rename congregation"
      (let [response (try-rename-congregation! session cong-id "New Name")]
        (is (ok? response)))
      (let [response (-> (request :get (str "/api/congregation/" cong-id))
                         (merge session)
