adding qeurywid and querywidmaster test functions
making conditional statement more robust
changes to ag1