                   (vec (map (fn [s] (:state s)) (deref output)))))
 
            ; Test with init
-           (dosync (ref-set output []))
+           (reset! output [])
            (doseq [state states]
              (r2 {:state state}))
-           
+
            (is (= [:bad :ok :evil :bad]
                   (vec (map (fn [s] (:state s)) (deref output)))))))
-           
+
 (deftest changed-state-test
          ; Each test stream keeps track of the first host/service it sees, and
          ; confirms that each subsequent event matches that host, and that

                           [{:tags ["foo"]} {:tags ["foo" "bar"]}]))))

         (testing "tagged (multiple tags)"
                  (let [r (ref [])
                        s (where (tagged ["foo" "bar"]) (append r))
                        events [{}
                                {:tags []}

  "Applies a seq of alternating events and intervals (in seconds) between them
  to stream, returning outputs."
  [stream inputs-and-intervals]
  `(let [out# (atom [])
         stream# (~@stream (append out#))
         start-time# (ref (unix-time))
         next-time# (ref (deref start-time#))]
