Fix provides/obsoletes and write testcase.