Add test cases for updateOrCreate/save and fix related issues