Fix behaviors for whitespaces

Also add a couple of tests.
4 files changed