Fix Pattern.clear(), add more unit tests.