     {:channel c
      :tailer  tailer}))
 
-(fact (let [lines                    ["a" "b" "c" "d" "e"]
-            file                     (File. "test/_work-dir/plop.log")
-            {:keys [channel tailer]} (tailer-and-channel file 100)
-            result-ch                (a/thread (doall (chan->seq channel)))]
+(defn stop-tailer-and-channel [{:keys [channel tailer]}]
+  (.stop tailer)
+  (a/close! channel))
+
+(fact (let [lines     ["a" "b" "c" "d" "e"]
+            file      (File. "test/_work-dir/plop.log")
+            t-and-c   (tailer-and-channel file 100)
+            result-ch (a/thread (doall (tailer-and-channel->seq t-and-c)))]
         (Thread/sleep 1000)
         (spit file "")
         (spit file (str (str/join "\n" lines)
                         "\n"))
         (Thread/sleep 1000)
         (println "Stopping")
-        (.stop tailer)
-        (a/close! channel)
+        (stop-tailer-and-channel t-and-c)
         (a/<!! result-ch)
         => lines))
-
 
 ;; TODO
 ;; Check that bug.

   (when-let [v (a/<!! c)]
     (cons v (chan->seq c)))))

(defn tailer-listener [c]
  (reify TailerListener
    (init [this tailer] ())

    (fileRotated [this]
      (println "Rotation detected"))
    (^void handle [this ^String line]
     (a/>!! c line))
    (^void handle [this ^Exception i]
     (println (str "exception: " i)))))
