hidl_test: move duplicated code to shared lib am: 30dc3dee3c
am: 716a8394a6

Change-Id: Ic797796a68d7fd58c529ad20aad448da8e65fa22