Move common code into a separate function.

test_get_valid and test_get_valid_key2 test tempurl with a
single key and two keys respectively. This change moves common code
for these tests into a separate function.

Change-Id: Ifee211285e27df03d041a4c357b7c1f0c96ed6a8
Merge "Move common code into a separate function."