Fix memoize decorator for 0.16(same fix as in #6685)

Instead of cherry-picking all the commits from #6685, which also pulls unrelated code, we just fix the decorator and don't move it like in salt's develop.
Merge pull request #6979 from s0undt3ch/0.16-merge-decorator

[ATTENTION 0.16 commit] Fix memoize decorator for 0.16(same fix as in #6685)