testutil: Common callback handling

Change-Id: I164a05aff4e8239be8c301b14648307648cf0634
Reviewed-on: http://review.couchbase.org/29685
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>