Added test and fixed tested issues