Re-apply proper use of mock, which was lost in a previous merge.