Fix default groups creation
Use in memory database for testing
A few permission fixes that I discovered during writing the permission tests
Added permission tests