Add tests and source fixes for failing tests