Feature/permissions cache tests

Tests for #1792 backport