Bug 862461 - Add in Mongo connection error handling.
Add middleware checking if Mongo Connection is active.
Restructure when connection was made for easier passing around of object
Rebase fix for Mongo middleware