Improve parameter checking and error behavior
Remove some pre-php53 todos & workarounds
increase coverage