Fixed bug in patch helper and added new tests