Check study access rights and study exists

 Fix #445
flake8 on travis does weird things... recommend running it manually on your computer...