                         mh (mql/message-handler q nil
                                                 delay-message process-message)]]
             (binding [*logger-factory* (atom-logger log-output)]
-              (mh (append-attempts i (tqueue/store-command q "replace catalog" 10 "cats" {:certname "cats"})))
+              (mh (-> (tqueue/store-command q "replace catalog" 10
+                                            "cats" {:certname "cats"})
+                      (add-fake-attempts i)))
               (is (called? delay-message))
               (is (not (called? mql/discard-message)))
 

  [command publish-var discard-var & body]
  `(test-msg-handler* ~command ~publish-var ~discard-var *db* ~@body))

(deftest command-processor-integration
  (let [command {:command "some command" :version 1 :payload "\"payload\""}]
    (testing "correctly formed messages"

              mh (mql/message-handler q nil delay-message process-message)]
          (with-redefs [mql/discard-message (mock-fn)]
            (binding [*logger-factory* (atom-logger log-output)]
              (mh (-> (tqueue/store-command q "replace catalog" 10
                                            "cats" {:certname "cats"})
                      (add-fake-attempts mql/maximum-allowable-retries)))
              (is (not (called? delay-message)))
              (is (called? mql/discard-message))
              (is (= (get-in @log-output [0 1]) :error))
