fixed toString and toBinaryString

The toString and toBinaryString methods would not produce the correct
result when the word store had empty indexes. This commit fixes those
bugs, as well as adds the corresponding test for that case.