I was about to write a similar extension. It works well. If you add
app.command.GotoNextLayer()
app.command.GotoPreviousLayer()
before the refresh on the LayerUp/LayerDown functions it will refresh the layers ui and keep the current layer highlighted.