Finish writing getenv tests and bugfix