Fixes #55 Added tests to check sub permission logic.