Alberto, was that snippet part of a service that failed? If it says 'template already exists' and you can't see it, you've essentially created a ghost entity; that's an entity that exists in memory but is not committed to the database. You would always need to use a try-catch block around create scripts so that you avoid creating ghost entities.
If you have ThingWorx 7.2.0+, please take a look at our Ghost Entities Cleaner extension in our Marketplace. Here is a KCS article that expands on the topic of detection, prevention and removal of said entities. With that being said, the create code you provided should work (on its own).