clean up some environment tests.
clean up some environment tests.

Modified the following:
* Attempt to use GDAL_DATA if needed
* Avoid writing file for gdal-config
* Move repeated code into functions
njwilson23/rasterio,clembou/rasterio,njwilson23/rasterio,perrygeo/rasterio,perrygeo/rasterio,youngpm/rasterio,brendan-ward/rasterio,kapadia/rasterio,njwilson23/rasterio,brendan-ward/rasterio,johanvdw/rasterio,youngpm/rasterio,perrygeo/rasterio,kapadia/rasterio,brendan-ward/rasterio,johanvdw/rasterio,youngpm/rasterio,clembou/rasterio,kapadia/rasterio,clembou/rasterio,johanvdw/rasterio