fixed a bug with nested lists and invalid html
added unit tests