   [env]
   (vec (sort-by #(::order (meta %))
                 (filter #(::local (meta %)) (keys env)))))
+
+(defn- find-local-args
+  "Returns a vector of the function argument forms of locals bound by
+  with-context in the environment."
+  [env]
+  (vec (map #(::arg (meta %)) (find-locals env))))
 
 (defmacro context
   "Creates a context object, using existing local contexts.

  (let [[doc args] (get-arg string? args)
	[opts body] (get-options args)
	metadata (merge (standard-metadata &form doc) opts)]
    `(with-meta (fn ~(find-locals &env) ~@body)
       '~metadata)))

(defn run-tests [& args]

(defmacro with-context
  "Establishes a local binding of sym to the state returned by context
  c in all groups and examples found within body."
  [form c & body]
  `(let [~(with-meta (gensym) {::local true
			       ::order (local-counter)
			       ::arg form}) ~c]
     ~@body))

(defmacro wrap-context
