Check study access rights and study exists

 Fix #445
Can you put a comment for the magic number #2?