Added an internal test suite and debugged functions.