The problem is caused by the way XalanJ 2.4.1 handles whitespaces in XSLT;
Stylus needs not to completely ignore those whitespaces in debug mode to
let you properly follow the execution line by line, but that confuses
XalanJ in this case, as it considers the definition of {test} complete as
soon as it finds a newline. A workaround is to remove whitespaces between
{test} and the {xsl:attribute} elements.

XalanJ 2.5.1 fixes this and other problems related to namespaces in
xsl:attribute elements; Stylus Studio 5.1 bundles the newest XalanJ
version, so the problem will just go away in the next version (beginning of
December).

In the meanwhile, we have created a limited workaround which addresses the
behavior you are seeing; we are making this available as a maintenance
update in a couple of days (BL127h).