fix include/exclude bugs and add more tests

I'll make some comments on the mailing list