api tests and some cleanup