Fixed build, bugs. Added tests for sqlite3 wrapper.