added exceptions. added base implementation query and tests