fix tests to consistenly run by cleaning up mongo each time correctly.  move null check to fix odd null pointer exception