DJSON-11: Fix printing of unnecessary commas with value-fn

Adds state to loop remembering whether any key/value pairs have been
printed before, to distinguish whether to print a comma or not.

Changes test case to use sorted-map, both for determinism in the
order, and to exhibit the bug with the uncorrected version of
write-object.

Signed-off-by: Stuart Sierra <mail@stuartsierra.com>