ireadChar function and tests