Fix the builtin min() and max() functions (and add tests).
Fixes #539
Merge pull request #544 from lurch/fix-minmax

Fix the builtin min() and max() functions (and add tests).