Fix nif-mode and eunit_nif tests.

- start with scott's commit 0d3acb0
- fix the issue introduced in 6c97173 more mininally
- ifdef out env reading even though it doesn't matter