Re-factor _stop_dhcp and add tests