Added handling of some special cases and more tests