Added unit tests,  and  prototype functions.