[865758] Improved error handling of MongoDB connection problems

Added a mongoDB healthcheck middleware, and refactored some code to allow for it in the current architecture.

Ref: https://bugzilla.mozilla.org/show_bug.cgi?id=865758