Added Reference test
Fixed issue with formatting data for sql
removed occurence of duplicate queries.