simplifies tests code, adds grant privileges and fixes bug in empty search