add has_permission
improve code documentation
improve test coverage