Refactored some test cases to remove duplicate lines of codes.