Check study access rights and study exists

 Fix #445
It's one of the tables that needs refactoring a la #292