add some tests & fixes for patch module