What can I do about electric code violations in a rental unit?
I had this same situation.  I made a (written) list of issues (with pictures) and gave it to the landlord.  When it became clear that the landlord would not fix them, I called an inspector.  It turned out that there was a completely different department overseeing residential safety inspection vs. building code inspection, but after getting that sorted, they gave the home a free inspection and gave the landlord a fine and deadline to fix the issues.  The landlord was understandably upset and asked us to leave, and we happily signed the lease-termination.  I maybe should have told the landlord that I was going to refer the issues to the city by such-and-such a date and this may have avoided involving the city and angering the landlord.  We probably would have been let out of lease under better terms, but there would have been no incentive for the landlord to fix anything and the cycle would have begun again with the next tenants.  

I recommend you give the landlord every opportunity to fix your concerns, and seek a mutual lease-termination agreement if/when this fails.  Pay your rent!  If you don't and this goes to court, then It'll just end up looking like the you wanted out all along and used the safety issues as an excuse.  If the inspector condemns the place, and you are forced to move, then you can stop paying your rent.