The role of environmental variation and host gene flow on the vertical transmission and population prevalence of heritable symbionts