Working #2144: Reintegrated changes from #2138 and fixed test fail.

Now using instance variables for withCredentials.  Also fixed test failure.