Fixed some compilation errors, that got introduced with the new changes
Wrote unit tests for verifying the values generated during query
execution and in that process fixed multiple issues.