Add unit tests, mainly in the core
#66 and #79