Added TOTAL and DISTINCT in function. Some tests for functions