Fix delete study function and update tests