Fixed pyflake warnings and prevented duplicated test runs