Fixed bugs with upsert and insert

Upsert didn't account for the fact that insert could return a duplicate
key error after unlocking the buckets and performing cuckoo hashing,
where in the meantime another thread performed an insert on the same
key. Also if the last duplicate key check in the insert failed, we
forgot to unlock the buckets before returning failure. Also updated the
count_freq test to insert uint32_t for a wider range of numbers.