Fix pyflakes errors in tests