redtest

Test Plan:
<see below>
Final version without factoring out common subexps for optimizing conditionals

Test Plan:
<see below>