Bug - contains() returns true without check

contains() method, which checks whether a word is present in the DAWG,
returns true without checking whether a valid word ends at that index.
Alternatively, it returns true when the input is a prefix of some word
in the dictionary, false otherwise.