Fixed issues when run with php-ng

Fixed several fails I met

thanks