   [[:logging logconf/configure-timbre [:timbre]]
    [:cassandra ams/create-test-session [:config :alia-session]]])
 
-(defn with-system
+(defn with-system*
   [sys f]
-  (let [system @(sys/system-map sys)]
-    (binding [*model-session* (:cassandra system)]
-      (f))))
+  (try
+    (let [system @(deferst/start! sys)]
+      (binding [*model-session* (:cassandra system)]
+        (f)))
+    (finally
+      (try
+        @(deferst/stop! sys)
+        (catch Exception e
+          (error e "error during test stop-system!"))))))
 
 (defn with-model-session-fixture
   "a clojure.test fixture which sets up logging and

   [taoensso.timbre :refer [trace debug info warn error]]
   [deferst :refer [defsystem]]
   [deferst.system :as sys]
   [slf4j-timbre.configure :as logconf]
   [manifold.stream :as stream]
   [er-cassandra.record :as r]

            {:keyspace "er_cassandra_test"
             ;; set to false to preserve db contents after tests
             :truncate-on-close true
             ;; :trace? :warn
             ;; :consistency :all
             }}})

