         {:status "error"}))))
 
 
-;;TEST
+;;Refactor
 (defn delete-evidence! [ctx evidence-id user-badge-id user-id resource-id resource-type]
   (try+
     (if (badge-owner? ctx user-badge-id user-id)

     (reduce (fn [r evidence]
               (let [property-name (str "evidence_id:" (:id evidence))
                     properties (some-> (select-user-evidence-property {:name property-name :user_id user-id} (into {:result-set-fn first :row-fn :value} (u/get-db ctx)))
                                      (json/read-str :key-fn keyword))]
                 (conj r (-> evidence (assoc :properties properties))))) [] evidences)))
  ([ctx badge-id user-id markdown?] (map (fn [evidence] (-> evidence (update :narrative u/md->html))) (badge-evidences ctx badge-id user-id))) )


(defn delete-badge-evidences! [db badge-id user-id]
  (if-let [evidences (select-user-badge-evidence {:user_badge_id badge-id} db)]
    (when-not (empty? evidences)
      (delete-all-badge-evidences! {:user_badge_id badge-id} db)
      (doseq [evidence evidences
              :let [name (str "evidence_id:"(:id evidence))]]
        (delete-user-evidence-property! {:name name :user_id user-id} db)))))

(defn delete-badge-with-db! [db user-badge-id]
  (delete-badge-tags! {:user_badge_id user-badge-id} db)
