separated legend code, modified legend test