Tests and code fix