Separate CKeyStore interface from its basic implementation

And move CCriticalSection cs_KeyStore up from CKeyStore to CBasicKeyStore. 
Also cleanup some dependencies.
This serves as preparation for #5208
@jtimon In #5196