PHP 5.5 fixes + unit tests