Updated working with patterns and added new tests