Adding sorely missing unit tests [WIP]

@atesgoral - finally started work on this