Improve templates factories
Fix test with factory instance