Firstly, this:
<xsl:for-each select "test/*">
<xsl:apply-templates select"."/>
</xsl:for-each>
is a rather longwinded way of saying
<xsl:apply-templates select"test/*"/>
Try this template rule:
<xsl:template match="p[ul|ol]">
<xsl:apply-templates select="*"/>
</xsl:template>
This will remove the p element around any ul or ol, which I suspect is what you really want. However, if you prefer to do this only after another p element, you can:
<xsl:template match="p[ul|ol][preceding-sibling::*[1][self::p]]">
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference