                                                                    #(throw (RuntimeException. "uh oh"))
                                                                    (fn [ctxt] (reset! on-error-fn-called? true)))))
           app                 (bootstrap-services-with-empty-config [broken-service])
-          test-svc            (get-service app :ShutdownTestServiceWithFn)
-          main-thread         (future (tk/run-app app))]
+          test-svc            (get-service app :ShutdownTestServiceWithFn)]
       (is (false? @shutdown-called?))
       (is (false? @on-error-fn-called?))
       (test-fn test-svc)
       (is (thrown-with-msg?
-            java.util.concurrent.ExecutionException #"java.lang.RuntimeException: uh oh"
-            (deref main-thread)))
+            RuntimeException
+            #"uh oh"
+            (tk/run-app app)))
       (is (true? @shutdown-called?))
       (is (true? @on-error-fn-called?))))
 

        (bootstrap-and-validate-shutdown
          [test-service]
          shutdown-called?
          #"java.lang.Throwable")
        (is (logged? #"Error during service start!!!" :error)
            "Error message for service start not logged."))))


          app             (bootstrap-services-with-empty-config [broken-service])
          test-svc        (get-service app :ShutdownTestServiceWithFn)]
      (logging/with-test-logging
        (test-fn test-svc)
        (is (thrown-with-msg?
              Throwable
              #"foo"
              (tk/run-app app)))
        (is (logged? #"Error occurred during shutdown" :error))))))

(deftest shutdown-on-error-error-handling
  (testing "Shutdown-on-error should never throw an exception."
