Secretary refactor

merging in changes from secretary - have added a test package with a secretary test file.