Motherwell comeback at Livingston boosts top-six hopes