Remove unused and duplicate code

Remove some unused and duplicate code from test_libvirt.py
and test_db_api.py

Change-Id: Ia9e68b68abbf391017a1127c0a15b97d50f147e9
Merge "Remove unused and duplicate code"