Validating that the requested device actually exists in devices array

Fixes #103.

@pdehaan r?