added mat_query tests and polished mat_query doc comments