Fixes #899: Issue in scalar-matrix MX operation

An alternative fix for #899.
Special care was taken that sparsities are never needlessly lost.
Passes all tests added in 8b098c1

Also fixes #897

(See also #900)