tests optimizations and fixes.

fixed a crash in B&F restricted