Fixed crash
Added test