Fix dependency injection and prepare command test