With legato stuff it's crucial to mute the other strings above and below. There's more than one way to do this but what seems easiest is to position your index finger so that the tip touches the string below and rests lightly across any higher strings. Justin covers this in his rock legato series, check it out if you haven't already. Another nice habit to get in to is to have the fleshy part of your hand at the base of your thumb lightly touching any string lower than the one you're playing. Of course if you're actually hitting another string when you hammer on you just need to be more accurate.