Fix SQL translation script and associated unit tests