Fixed NFA and DFA classes, and added test cases for them