Fix hooks, add more tests