If just the plastic housing for the wires is broken that part is avaiable seperately from the wiring harness. You need to closely inspect the wires at the plug to see if the insulation is cracking and coming off of the wires.If the insulation is craking then its time for a new harness. A faullty harness could be causing your problems. Its unlikely that the plug being loose would cause an idle problem since the cam magnet is not energised at idle. Plus if the plug was not connected it should set a fault code and turn on the check engine light as well. You mentioned that you found the cause of your fuel smell, what did you find?