Add error support. Expand tests for errors.

Doing a sort by null constant fails. So add test, verify and fix.