Use envvars (fix #2), rewrite unit tests, add flake8