   (testing "Testing that metrics are updated with result of action"
     (let [metrics-service (fault/service 1 100)
           latch (CountDownLatch. 1)]
-      @(service/submit-action metrics-service (fn [] 1) Long/MAX_VALUE)
-      @(service/submit-action metrics-service (fn [] (throw (IOException.))) Long/MAX_VALUE)
-      @(service/submit-action metrics-service (fn [] (.await latch)) 10)
+      @(service/submit-action metrics-service (success-fn 1) Long/MAX_VALUE)
+      @(service/submit-action metrics-service (error-fn (IOException.)) Long/MAX_VALUE)
+      @(service/submit-action metrics-service (block-fn 1 latch) 10)
       (.countDown latch)
       (is (= 1 (-> metrics-service :metrics :successes)))
       (is (= 1 (-> metrics-service :metrics :time-outs)))

      (is (nil? (:error f)))))
  (testing "If concurrency level exhausted, action rejected"
    (let [latch (CountDownLatch. 1)
          _ (service/submit-action service (fn [] (.await latch)) Long/MAX_VALUE)
          f (service/submit-action service (fn [] 1) Long/MAX_VALUE)]
      (is (= :max-concurrency-level-exceeded @f))
      (is (= :rejected (:status f)))
      (.countDown latch))))


(use-fixtures :each start-and-stop)

(defn- block-fn [result ^CountDownLatch latch]
  (fn [] (.await latch) result))

(defn- success-fn [result]
  (fn [] result))

(defn- error-fn [e]
  (fn [] (throw e)))

(deftest submit-test
  (testing "Submit action returns CLJ future wrapping result"
    (let [latch (CountDownLatch. 1)
          f (service/submit-action service (block-fn 64 latch) Long/MAX_VALUE)]
      (is (= :pending (:status f)))
      (is (not (realized? f)))
      (is (= :not-done (deref f 100 :not-done)))
