Added initial unittests and fixed some early spots