Tests and patches for SA-2014-002 and SA-2014-003 for 4.3

These are tests and patches for SA-2014-002 and SA-2014-003 for CiviCRM
4.3. I do have the patches separated out into separate commits, if you
just want to take those and not the tests as the tests had to make a few
modifications to some low level core stuff to get to work.

I'm also going to do a pull request for just the tests against the master
branch as well.