deep test refactoring and fixes. All Basic authentication related tests pass