small fixes to sql-rewrite to make the test run without errors

Got rid of some errors when running test.php in sql-rewrite. Please have a look.