Fixed bug with null reference
Added test's