Backported fix from master.

Change input parameters used as return values to references; change
cached values due to the correction; disable slow test case.