Montpellier Hérault Rugby survived a spirited Harlequins performance to reach the Heineken Champions Cup quarter finals.