Cio ignore fix

Fix is partially written by Ihno, but I adapt it to be more ruby and also add test cases.