Check if key is present and return an error if not

Fixes #32