Raycast not working

Hello, im new to box2d, but i have had some experience with physics engines on haxe.
I am trying to make a simple raycast, the raycasting part i just copied from the testbed example, On a level with lots of small rectangles raycasts miss quite often. I attached a swf so you can see the problem, press arrowkeys to move, and ctrl to raycast. If the shooter is on the left and bottom side the rays are quite accurate but as it gets further it misses a lot of obstacles. If you have any idea how to make this work help me pretty please
Code:
//apparatus.as
public function ray(target:b2Vec2):void {
         var p1:b2Vec2 = body.GetPosition()
         var p2:b2Vec2 = target;
         

         var f:b2Fixture = app.world.RayCastOne(p1, p2);
         var lambda:Number = 1;
         if (f){
            var input:b2RayCastInput = new b2RayCastInput(p1, p2);
            var output:b2RayCastOutput = new b2RayCastOutput();
            f.RayCast(output, input);
            lambda = output.fraction;
         }
         DebugDraw.graphics.lineStyle(1, 0xff0000, 1);
         DebugDraw.graphics.moveTo(p1.x * app.RATIO, p1.y * app.RATIO);
         DebugDraw.graphics.lineTo((p2.x * lambda + (1 - lambda) * p1.x) * app.RATIO, (p2.y * lambda + (1 - lambda) * p1.y) * app.RATIO);
//gets called like this apparat.ray(actors[0].body.GetPosition());
      }


on the swf attached press ctrl to raycast and see the problem with some bodies
after some experimentation i have come up with a solution myself. It seems that raycastOne returns a semi random object from all of those it hits, not the one it hits first, so i have to call raycastAll and sort which is first by myself.
My only question is if raycastOne is supposed to behave like this? Or is it a bug or i was using it wrong?
I know very little of raycasting, never tried using it.
But have you checked the testbed to see how raycasting is done there?
Also, this, sounds like what you encountered. It might help.
yes my code at first was exactly the same as in the testbed. Thanks for the link, ok so it seems raycasting is still new, i shouldnt have expected so much of it, however im happy that i found a workaround

Original thread: https://box2d.org/forum/viewtopic.php?t=5549