Add test and some cleanup on configuration codes