Extracting database name, username and password from mongoURI if provided. Added test to verify connection via mongoURI with and without database name.