separate utility functions

Signed-off-by: Kouhei Maeda <mkouhei@palmtb.net>
formatize result data for CouchDB

Signed-off-by: Kouhei Maeda <mkouhei@palmtb.net>