The reason is that you have defined lb inside a function -- main(), not as a global.
Either use globals, or use attributes directly accessible from your UI elements. Sender in your code will be the button--so sender.superview leads to your main view in this case, and sender.superview.lb.text='test' etc let's you store info in your own custom attribute names. Just be sure they are unique names that are not already attributes of ui.View.
When you are trying into to access subviews you can do
sender.superview['label1'].text='test'
if you originally define view names when you add them to your main view.
Or, you can add attributes of the button to point to it's target label,
B=ui.Button(...)
L=ui.Label()
B.target_label=L
...
#Then in your callback
sender.target_label.text='...'