Brian Graham fired United ahead in the first half and Nadir Ciftci added a superb second after the break, but Danny Wilson's late strike set up a tense finish at Tynecastle.
The hosts slipped closer to relegation after failing to find a leveller, while United moved within four points of third-placed Motherwell.
"I'm delighted with the three points and I thought we could have got more goals," said McNamara.
"We could have finished the game a lot earlier.
"We had some good opportunities and took the wrong option at times. But this is a hard place to go."
Ciftci netted his 14th goal of the season with a ferocious shot and he believed United fully deserved the three points.
"We kept going forward, it was hard for us, but I think we deserved it," said the Turkish forward.
"We had a lot of good chances but we did well and deserved to win the game.
"We have to give them some credit."
"I went out there and do with a smile on my face. I am enjoying my football."
Hearts boss Gary Locke refuses to give up hope, despite the club's desperate position, and could not fault the effort of his players.
"They have given us everything but we are lacking a bit of experience," he said.
"We just have to keep working hard and try and get a couple of victories before the end of the season."