better way to write unit test