Fix throw new \InvalidArgumentException

Fixes issue #46