Implement query function and UTs
Fix jslint errors