fix important bug + added test