Fixed expression patching

Added more unit tests