Effects of the electrostatic environment on the Majorana nanowire devices