Calculating has_second_ref only once for single_ref context. Change-Id: Ib1253e0606426850f53060a4c5303af86bf1c093