added tests and code for compare method