This is needed to get this failing test passing in rails. Also, I think its always a good practice to check for nil values & discard them instead of throwing an exception.
* Other tweakery to match MRI logic.