Add a boolToInt function in util.go
Delete everything from query_test.go. Start writing a robust query tester which calculates expected results for any query without touching the database.