Refactor getenv access using constructor

Another alternative to PR #6 and #7 including the idea of @bobthecow. 
Fixed.