Added ending patterns and a small test refactoring