Adding shelf button to current active shelf in Mel

Hi all, I am trying to run some mel commands and functions in which when user run the code, it will add a shelf button onto the current active shelf.

I managed to get it added onto the current active shelf, however, it will requires the user to perform 2 actions.
First, executing the code, then click on the newly created icon so that it can create the actual shelf button (I use polyCube for demo purpose…)

Any ideas on how to get rid of the first step?

Additionally there is another issue that I have, at line 18 ("misc_commands_menu"); I will get an error // Error: line 19: Flags must come before objects: -b // if I tried to go to the second step…
By chance, I inserted that and it make shelf button works but I suppose I may have messed up the portion for the popupMenu command. Is there anything that I can edit to make the code better?

global proc testShelf() 
{
global string $gMainWindow;
string $win = $gMainWindow;

shelfButton
    -enableCommandRepeat 1
    -enable 1
    -width 34
    -height 34
    -label "Test"
    -annotation "Test for shelf button add on to current active shelf"
    -image "polyCube.png"
    -style "iconOnly"
    -marginWidth 1
    -marginHeight 1
    -sourceType "python"
    ("misc_commands_menu");
    popupMenu -b 1;
        menuItem -stp "python" -l "Sub Menu Item 01" -c "print 'hello, this is working!'";
        
showWindow;
}

scriptToShelf "tmp" testShelf "1";