Added two tests for the corner and reverse cases and also added a couple optimizations to the evaluation code.