Fix compilation issues.

We cannot pass temporary objects to non-const references.
Simplify test cases.