Check study access rights and study exists

 Fix #445
Trying to keep all the error raising logic in one block. Doesn't need to be but to me it keeps it logically sequestered.