Added several tests. There is a bug related to special cases.