tests/server: add shutdown to cleanup server thread
statistics: add method to count documents per type