Added test with query and cast