Fix one-off patching bug; Add more unittest