Added some unit tests

Hi,

I wanted to add some tests for edge cases. Some are not working yet.
I'll try to add a test for each bug I'll find from now on.