Of course, but you are not setting anonymous user as current user to the repository, so below the Content is loaded using administrator user. You need something like this:

```php
$anonymousUser = $userService->loadAnonymousUser();
$repository->setCurrentUser( $anonymousUser );
```