Improve ValueRef coverage and fix a bug