Check study access rights and study exists

 Fix #445
fixed. Surprised flake8 didn't complain.