W production and the search for events with an isolated high-energy lepton and missing transverse momentum at HERA