[WIP] Add some unit-testing and some minor changes