count_foo uses expanded u1db count method.

Other fixes in the commit:

* Correct the semantic for the recent flag (reset)
* Minor unicode fixes.
* Use a field for tracking the last_uid

In general, this tries to squash all the quick and naive methods
that were relying on evaluating all the message objects before returning
a result.

Further work is still needed, planned also for 0.5 release.
get_by_index needs to be indexed too.