Updated unittest to use api appropriately and to tearDown database.