Added rigrorous tests to all functions.