testbase: Use the new APIs for writing refs