REST API can do aggregations, various fixes

- as for now, only "count" is supported
- more can be relatively easily added by adding the appropriate method
in db.py (see "count" method) and editing _aggregate() in rest_api.py to
enable the aggregation
- routes in rest_server.py now return data as a string to avoid errors
with numbers
- small fixes in rest_server.py