hey, I am still not able to understand the query... what is the use of your last If statement, you are already doing the same in the above statements, may be you can exit the test at that stage only. I just tried the code and it works perfect on my side.
Please format the code if you are posting any.. use. the post becomes much readable using this.
Please format the code if you are posting any.. use
Code:
....your code....