Deal with misconfigured vaults. Added tests too.

@jeremy