added comparison functions and lots of tests