Fixed patch handling rest & #:optional, with test cases.