Interesting. I do something similar like this:
cat $script | ssh $server bash
Haven't found a case where this fails yet (but I'm sure it's out there).Edit to add this also works nicely:
ssh $server bash < $script
Edit to add that I experimented a little and this is a simple way to run remote one liners via ssh: ssh $server bash <<< 'cd /tmp; pwd'