Fix iterator error conditions

* Don't continue in iter_init() until parameters are validated.
* Don't leak key when iter_start() fails.