Unit tests

See #184. The unit tests for `replace()` catches #178 and #117, I'll make a fix for both tomorrow.