a small optimization
Added test
Added #27