fixed downgrade bug and added test case