Change check below and add a bunch of unit tests