Fix segmentation fault with tests