Permission refactoring

* Clean the test to make sure the DB is cleaned properly