internal/v4: implement stats endpoint

internal/v4/stats.go and internal/v4/stats_test.go are directly derived from
code in _old, although simplified to return only JSON-formatted results.

This required a fair number of fixes to other code, which
unfortunately aren't that easy to pick apart now, including the
following:

- internal/charmstore: make stats counter tests less hacky.

Because the internal/v4 tests are outside charmstore, delving
directly into the database to tweak the time stamps seemed unwarranted,
so added IncCounterAtTime and changed internal/v4 tests and existing
internal/charmstore tests to use it.

- internal/charmstore: move mongojs condition into storetesting.

This avoids duplicating the logic to determine whether tests requiring
mongodb embedded javascript can be run.

- internal/router: universal ParseForm.

This clears up responsibility for who should call ParseForm.

- internal/router: strip prefix from global handlers

This makes the global handlers (including /stats/counters) consistent
with other handlers in router.Handlers.

- internal/router: add ServeMux, NotFoundHandler

The original /stats/counter tests tested http status of paths which previously
returned an http.StatusNotFound status but with a non-JSON body.
The above two handlers make the not-found pages consistent
with the rest of the API.

- params: add ErrForbidden, ErrBadRequest

The original /stats/counter tests tested for statuses which our
current code was incapable of generating. The above two
errors make it capable.
This should be LGPLv3.