Serialize test properly

... and of course add tests for saving and loading state :)