Check study access rights and study exists

 Fix #445
self doesn't work outside instantiated objects, since they need self in the definition.