Added more test coverage and more sql functions