allow PerlIO layers to be passed in rather than encodings; improve tests