Fix stubs setup and exception message formatting

Fixes time-dependent bug in test case stubs setup that could result
in stubs being unset by GC.

bug 1205091

Change-Id: Ic0d97bd1f96e42631c1ba3e1eaf4cf74b36140b2
Merge "Fix stubs setup and exception message formatting"