Some improvements to util.secure_compare