Why is electricity turning off as soon as fixture is connected
In layman's terms: "Pen testers" will detect an induced voltage in a conductor. Similar to a static voltage. As soon as you put a load on that conductor the voltage does not have any power behind it so it disappears. (Imagine trying to use a 9 volt battery to start your car. There is voltage there, but very little power.) If you have a solenoid meter (wiggy) or a digital multimeter you will get a more accurate reading. Which apparently is zero, since when you connect the fixture the voltage disappears. 

Recheck your wiring. If you added an electrical box I would suspect that first. Caution, a white wire running to a switch is NOT a neutral wire. It is used to supply the switch with power and the black returns from the switch. The white should be re-identified with tape as black. 

Good luck!