United scrape past Hearts