Fix for bug Blades/BLD-152. Added test for bugfix. Optimized bug fix.