Fix functions without query and add tests