Tests added, one hidden bug fixed