More refactoring of how keys, passwords and secrets are stored

includes a working loopback and tempfile cleanup in endgame()
and several changes in order to avoid saving anything on disk
WIP addressing #124 and #126
small fix to tests