Added test case for #240 and fixed ternary operator
Code formatting