Added and fixed patcher tests and two uncovered bugs

Change-Id: I25639436313879d145354fadaa053f900690116d
Merge "Added and fixed patcher tests and two uncovered bugs"