Fix ScalarValue comparison behaviour

Also move doctests that didn't get checked.