fail fast by an invalid stream
refactor tests to use PassphraseKeyServices and added more tests