Fix the test and optimize the creation of Patterns