Now properly calculating lower threshold values too tests passing and some
cleanup