Go unit tests added and master code partially re-written