added query method and some tests