Final fixes for new Security, improved unit tests