fix working directory under unix
fixed logging of queries
added tests