 ;; a test-session is just a spy-session which will initialise it's keyspace
 ;; if necesary and will truncate any used tables when closed
 (defnk create-test-session
-  [{contact-points nil} {port nil} {datacenter nil} {truncate-on-close nil} keyspace :as args]
+  [{contact-points nil}
+   {port nil}
+   {datacenter nil}
+   {truncate-on-close nil}
+   keyspace
+   {trace? nil}
+   :as args]
   (create-spy-session
    (merge
     args

             _ (alia/execute alia-session (str "USE " keyspace ";"))]
        (return alia-session)))))

(defrecord AliaSession [keyspace alia-session]
  Session
  (execute [_ statement]
    (execute* alia-session statement {}))
  (execute [_ statement opts]
    (execute* alia-session statement opts))
  (execute-buffered [_ statement]
    (execute-buffered* alia-session statement {}))
  (execute-buffered [_ statement opts]
    (execute-buffered* alia-session statement opts))
  (close [_]
    (shutdown-session-and-cluster alia-session)))

(defnk create-session
  [contact-points datacenter keyspace :as args]
  (with-context deferred-context
    (mlet [datastax-session (create-alia-session* args)
           :let [alia-session (->AliaSession
                               keyspace
                               datastax-session)]]
      (return
       [alia-session
        (fn [] (s/close alia-session))]))))

    SpySession
    KeyspaceProvider]))

(defn- execute*
  [alia-session
   statement
   {trace? :trace?
    :as  opts}]
  (aliam/execute
   alia-session
   (let [str-statement (if (string? statement)
                         statement
                         (h/->raw statement))]
     (when trace?
       (if (true? trace?)
         (debug str-statement)
         (log trace? str-statement)))
     str-statement)
   (dissoc opts :trace?)))

(defn- execute-buffered*
  "execute a statement returning a Deferred<Stream<record>>"
  [alia-session
   statement
   {trace? :trace?
    :as  opts}]
  (return
   deferred-context
   (aliam/execute-buffered
