it works now, and has more test cases;