Added test for compact
Added implementation of compact