Fixed style check failure due to pep8 upgrade

Upgraded `pep8` tool enforces `E713` style-check (i.e. test for membership should be `if "key" not in container` instead of `if not "key" in container`). Fixed relevant code to address this convention.