Add test for export_env_dir and handle trailing new lines