fix border, add unit tests