Fixed some failing tests for PHP 5.3

Unfortunately, to fix these errors I've added some horrible hacks :(