Fix for Bug #3251

Fix for Bug #3251, plus fixed a couple of regular expressions. Also also added tests.
All Blast tests pass.