   [storage-spec account]
   (let [st (storage storage-spec)
         validated (->> account
-                       (before-update-validation st)
+                       (before-validation st)
                        (validate-account st))]
     (if (validation/has-error? validated)
       validated
       (do
-        (update-account st (prepare-for-save validated))
-        (prepare-for-return (find-by-id st (:id validated)))))))
+        (->> validated
+             (before-save st)
+             (update-account st))
+        (->> validated
+             :id
+             (find-by-id st)
+             prepare-for-return)))))
 
 (defn delete
   "Removes the account from the system"

   (s/optional-key :parent-id) s/Int})

(declare find-by-id)
(defn- before-update-validation
  "Adjust account data for validation"
  [storage account]
  (cond-> account
    (nil? (:entity-id account))
    (assoc :entity-id (:entity-id (find-by-id storage (Integer. (:id account)))))))

(defn- prepare-for-save
  "Adjusts account data for saving in the database"
  [storage account]
  ; convert account type from keyword to string
  (cond-> account ; TODO should coercion handle this?
    (:type account) (update-in [:type] name)))

(defn- prepare-for-return

    (if (validation/has-error? validated)
      validated
      (->> validated
           (before-save storage)
           (create-account storage)
           prepare-for-return))))

