import Promise
do not run hooks twice
code tidying
hooks refactor
amend tests
Merge pull request #1841 from overlookmotel/hooks2

Changes to hooks