Refactor and automaize the test.