Fix bug in test_wrappers dev. filtering

Was checking for non-null error when should have been checking
for null error.
Fix/refactor devquery/device_query for custom queries

Only uppercase custom device_query queries were working, now all
work. This required a small refactoring in the devquery module.