Added query function
Added test for this and demo database