Add testing single input.
Fix some bugs found in testing.