Add missing specs

I also made some refactoring and fixed few bugs.

I used `i('string')` to construct strings in the tests. The `i` method just froze the string. This was to ensure that original input was never mutated.