Fixed type error and enhanced the tests of the apply-patch command