More database queries and tests