Check $query is passed before checking method. Fixes #149.