Hello: Normally in my part of town water heaters at 240 volts are hard-wired. So, this suggests the plug as well as the junction box on top of the heater are the two places where the electrical connection may be bad and in need of a look see. The connections above the high limit come before the thermostat. Treat everything as if it was live