Fixes in MIN/MAX aggregate functions, added basic unit tests.