added missed tests and some code cleanup