Mongo: Restructure conditionals to improve readability, and minor changes

Tries to handle error or exception cases and return, and continue on with the general case. This reduces the indentation level overall.

Since `mongo_run_command` can accept a null `out`, the code to handle that case doesn't need to be repeated in the functions which call it.