Ok.. now I have tested with another PIC,a PIC16F887 and then it works, the "bug" is gone.
So why does it hang with a PIC18F2550, PIC184550, and 18F4520?

Does it have something with the config fuses to do? what have I missed?