fixes geraintluff/jsv4-php#10 and added the relevant unit test