Normalize path to get rid of ``..`` parts.
Add before_terminate and after_start hooks and make it simple for plugins to add their own hooks.
Refactor tests to use more pytest features and expose some fixtures for reuse.