Add network hooks and fix unit tests