Added curly braces to if statment
Added test for bug fix #582. Test Passes