Added tests. Fixed lock type in insert.