Enhance environment variable usage

Fetch it so an error is thrown closer to where the error is. Add it to sample env since it's required