Added tests for hooks.py
Fixed various bugs in hooks.py