Fix file version SQL stuff; start writing tests for SQL statements