improved compare() function test