Fix sql for unit test and update process