Another round of unit tests fixing

Also fixed an issue with link permission checking for nil user