Fix tabs and add unit tests