fix problems detected by pyflakes
fix bug found by whit537 while testing bitbucket auth