i have had all of the above at some stage, as oily said the first thing (easiest) is to clean the lamp fittings with wd40, usually solves most of the lighting snags.
with the dipped/main beam i have had the dashboard switch be the problem but this can be checked with a multimeter for continuity, otherwise swap the cables for side with dipped to see if the fault swaps over
beware of taking it for granted that if you have 12V at the lamp holder (or anywhere along the system without the lamp in) that your cabling is good, the cable could have continuity without a load but as soon as you put the lamp back in and you start to draw current the cable may be unable to deliver the neccessary to light the lamp. the usual clues that your cableing may be in this state are that the insulation may have gone hard/brittle or that the wire will be oxidised (black in colour). answer - run new cable!
hope some of this helps.