Add DI tests & fix some issues

Replace #233.

ping @XWB @asm89