Added and fixed permission tests

- fixed test for db functions
- added tests for different users
Merge pull request #2579 from sebgie/permission-tests

Added and fixed permission tests