Remove last SQL statements from tests: Also fix bug with loading categories