         func-name (:function-name p)
         sb-tester (get-tester (:restricted p))]
     (try
-      (loop [t tests]
-        (if (empty? t)
+      (loop [[test & more] tests]
+        (if-not test
           (mark-completed id)
-          (let [testcase (replace-str "__" code (first t))]
+          (let [testcase (replace-str "__" code test)]
             (if (sb sb-tester (read-string testcase))
-              (recur (rest t))
+              (recur more)
               (do
                 (session/flash-put! :code code)
                 (flash-error "You failed the unit tests."
-                           (str "/problem/" id)))))))
+                             (str "/problem/" id)))))))
       (catch Exception e
         (do
           (session/flash-put! :code code)

  (:require [sandbar.stateful-session :as session]))

(defn get-solved [user]
  (into #{}
        (:solved (fetch-one :users
                            :where {:user user}
                            :only [:solved]))))

(defn get-problem [x]
  (fetch-one :problems :where {:_id x}))

(defn mark-completed [id]
  (if-let [user (session/session-get :user)]
    (do
      (when (not-any? #{id} (get-solved user))
        (update! :users {:user user} {:$push {:solved id}})
        (update! :problems {:_id id} {:$inc {:times-solved 1}}))
      (flash-msg "Congratulations, you've solved the problem!" "/problems")) 
    (flash-msg "You've solved the problem! If you log in we can track your progress." "/problems")))

(defn get-tester [restricted]
  (into secure-tester (map symbol restricted)))

(def sb (sandbox*))

