Testing environmental and genetic effects in the presence of spatial autocorrelation