MT#7471 Implement contract pref loading.

(cherry picked from commit 471aa9a994930ae7b91ef2a926f635354802b543)
MT#7471 Try to fix mysterious test.

(cherry picked from commit 2aafd9de0fc08fe856ed523f1f9a3f41502c872e)
MT#7471 Another test fix.

(cherry picked from commit 173a85a512e6849109ef6d8a9a049e870f52f2f1)
MT#7471 Fix loading contract prefs.

(cherry picked from commit 11e14af6816694910f628baf49008355f7b0ab39)