MODE-2042: Optimized permissions checks. Added Testcase