Fixed bug in safeQuery, first part of test

Fixed bug in DB::safeQuery
Created test case for DB class and created first test for safeQuery