Fixed spaceless tag stripping too much (#526)

Fixes #526. This moves the whitespace trimming away from a token based replace to a whole output based replace. Another words it does the replace on the entire final string instead of for each token that makes up the final string.

Also I changed the tests for how macros and the spaceless tag behave. I think that if you create a macro in a spaceless tag the macro should not be stripped of white space unless it is actually used in a spaceless tag.