Fixed active pattern bug, added regression test