Add AMR comparison test, fix some bugs