fix logical espression issue
tests for logical expressions + slight optimisation of ternary operation