Add more tests and code clean up.