Add some assertions and fix test script